Hi all,
I have a google map which show results of a search and plots markers on the
map, I need to make it so that the map zooms to the extent of the markers
which have been placed on the map.
At present i have the following code which is successful in displaying the
map and its markers but i can not get the map to zoom to the extents, at
present it is set to specified zoom level.
function initialize() {
var latlng = new google.maps.LatLng(<?php echo $Lat
?>, <?php echo $Lng ?>);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new
google.maps.Map(document.getElementById("MapCanvas"),
myOptions);
<?php foreach ($Results as $row): ?>
var myLatlng = new google.maps.LatLng(<?php echo
$row['Lat'] ?>, <?php echo $row['Lng'] ?>);
var marker = new google.maps.Marker({
position: myLatlng,
title:"<?php echo $row['DealerName'] ?>"
});
marker.setMap(map);
<?php endforeach; ?>
}
I am populating the longitude and latitude via php and the results which are
being pull by a query to my DB at present.
James
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-maps-js-api-v3/-/b3MtTTBzd0pGUW9K.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.