Hi, I have pasted some code bellow that I am using to draw markers on google maps. The problem is some of the markers are hidden and I want to use the GLatLngBounds to make sure that all the markers are displayed and an appropriate zoom level is used.
I have given this a try but there is some problem in my code that I
have no clue about. Any one here spot anything that might fix my
problem.
Cheers - Zahid
<script type="text/javascript">
//<![CDATA[
var map = new
GMap2(document.getElementById("map"));
map.addControl(new
GSmallMapControl());
map.setCenter(new
GLatLng(0,0),17, G_NORMAL_MAP);
var sw = new GLatLng(51.675507,
-0.468292);
var ne = new GLatLng(51.2563,
0.248566);
var bounds = new
GLatLngBounds(sw, ne);
<?php
$sql = "SELECT * FROM postcode";
$result = mysql_query($sql);
$max = mysql_num_rows($result);
$num = 0;
echo 'var postcodes= new
Array('.$max.');';
while($row =
mysql_fetch_array($result))
{
$postcode =
$row['postcode'];
echo
'postcodes['.$num.']="'.$postcode.'"; ';
$num = $num + 1;
}
echo '
var x=0;
for (x=0; x<'.$max.'; x++)
{
var postcode_java =
(postcodes[x]);
localSearch.setSearchCompleteCallback(null,
function() {
if
(localSearch.results[0])
{
var resultLat = localSearch.results[0].lat;
var resultLng = localSearch.results[0].lng;
var point = new GLatLng(resultLat,resultLng);
bounds.extend(point);
placeMarkerAtPoint(point);
}else{
alert("Postcode not found!");
}
});
localSearch.execute(postcode_java + ", UK");
}';
?>
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel
(bounds));
</script>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
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-API?hl=en
-~----------~----~----~----~------~----~------~--~---
