Link to home
Start Free TrialLog in
Avatar of Nick_SD
Nick_SD

asked on

Can I zoom in on a google map marker

I have a page which loads up 20 markers into a google map
http://offers.ftvdirect.co.uk/list.asp

I would like to zoom in on the map when the user clicks on the left hand side markers

has anybody got any code which will let me do this

thanks

Avatar of Sudaraka Wijesinghe
Sudaraka Wijesinghe
Flag of Sri Lanka image

I don't have any sample code. But I believe this can be done with GMap2.setCenter method.

http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GMap2.setCenter
Avatar of Nick_SD
Nick_SD

ASKER

I was really wanting the map marker to show the bubble and centre on it when selecting the corresponding letter
Can this be done  ?
I'm speaking only on theory here, I haven't tried this myself. I think its possible with setCenter.
I assume you already know the geo location of the pointer, so simply call setCenter with that position and the zoom level you want.
map.setCenter(new GLatLng(lat, lon), 10);

Open in new window

Avatar of leakim971
Avatar of Nick_SD

ASKER

the mapcentering appears to get rid of existing markers on the map
and simply create a new one.
Avatar of Nick_SD

ASKER

@leakim971 the markers are off the map , the sample you sent was on map (i think)
line 347 to 349 replace :
                        GEvent.addListener(marker, 'click', function () {
                            marker.openInfoWindowHtml(locdesc);
                        }); 

Open in new window

by :
				GEvent.addListener(marker, 'click', function () {
					map.setCenter(marker.getLatLng(), 14); // 14 is the zoom
					marker.openInfoWindowHtml(locdesc);
				}); 

Open in new window

leakim971-486572.flv
Avatar of Nick_SD

ASKER

thanks but this is "in map clicking" ,it  looks great but need this to happen from a click outside the map take a look at this link http://offers.ftvdirect.co.uk/list.asp

you will see what i mean , links on the left outside the map.

im sorry if im missing the obvious here. If I can call the function from outside the map can you show me what im missing

>a look at this link http://offers.ftvdirect.co.uk/list.asp

yes, but please confirm it don't work
Avatar of Nick_SD

ASKER



yes when the user click on "A" inside the map it centers and shows the box, (thanks for that)

my initial request was when the user clicks on the left hand side markers (out of map)
the map zooms into that marker

can this be done or am i missing the point?

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nick_SD

ASKER

great thanks

yes thats superb , anyway to popup the info box on the marker or am i asking too much
not with your current code because your sidebar and markers are currently in different world
Check this example to see if it help you rebuild your page :
https://www.experts-exchange.com/questions/27107049/Google-Maps-Route-description-from-multiple-markers-Javascript-Drawing-polyline.html?cid=1131&anchorAnswerId=35999654#a35999654

Avatar of Nick_SD

ASKER

ok thanks for that, Im not sure why on earth they make this so complicated

Nick