...

View Full Version : Google Map API V3 Marker Focus



digitalclubb
11-11-2010, 09:34 AM
Hey Guys,

I am currently building a web app that uses Google Maps V3 api.

You select a check box which then shows a marker on the map.

My issue is, when you select and the marker is placed, I need the map to focus to that point, it currently embeds but doesn't focus.

Is there a particular function I could use to achieve this?

My current code is shown below:


var locations = [
// Longitude, Latitue, Content, Country Code, City Name
[51.481383, -3.114967, holidayOverlay, 'UK', 'Cardiff'],
[52.362393, 4.893379, holidayOverlay, 'NL', 'Amsterdam'],
[48.852314, 2.350089, holidayOverlay, 'FR', 'Paris'],
[40.18884, -3.716812, holidayOverlay, 'SP', 'Madrid'],
[53.800651, -4.064941, holidayOverlay, 'IT', 'Rome'],
[42.041134, 1.889648, holidayOverlay, 'SP', 'Costa Brava'],
[36.79334, 27.234421, holidayOverlay, 'GR', 'Kos'],
[37.014581, -7.933888, holidayOverlay, 'PT', 'Algarve'],
[28.358776, -14.05426, holidayOverlay, 'PT', 'Fuerteventura'],
[29.046854, -13.589973, holidayOverlay, 'SP', 'Lanzarote'],
];

// Only create marker when checked
for (i = 0; i < locations.length; i++) {
if (locations[i][4] == location) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][0], locations[i][1]),
map: map,
icon: plotImage
});
var title = locations[i][4];
var content = locations[i][2];
}
}

I have left a lot of the code out to save you a headache.

Thanks.

Old Pedant
11-11-2010, 06:57 PM
map.setCenter( theCenterGLatLng )

digitalclubb
11-12-2010, 12:43 PM
Amazing.. Thank you :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum