[eluser]JamesTaylor[/eluser]
Hi Guys,
first of all sorry that this isn't specifically codeigniter relevant!... but it is within a codeigniter site!
Hopefully there is someone on here who knows their way around google maps APIv3!
I'm trying to get a google map, which is showing some search results of dealerships location on the map using markers which i have achieved. However i would like the map to zoom to the extent of the markers which are being displayed - for example if someone searches dealers near to Liverpool and there are 5 dealers within close proximity the map will show all 5 markers with a tight zoom around the locations, but if someone searches Bradford and the nearest dealers are in Liverpool the map will show the markers but with a wider zoom level - so it shows the location searched and the nearest dealers in Liverpool.
The code I have at present is:
Code:
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; ?>
}
How can i make it so it zooms the extent of the markers being plotted?
Thanks, James