On May 1, 8:34 am, happyneil <[email protected]> wrote: > Hi there, > Can anyone help me with this issue. How would I go about changing > map.setCenter in such a way as to display all the clustermarkers > that I have created from my MSSQL? I have tried to look at how > other > examples have done it > (e.g.http://groups.google.com/group/google-maps-api/browse_thread/thread/2...), > but I can't seem to figure out how I can apply this to my Google > Map. Any example code and advice is greatly appreciated!
I would think that centering the map and zooming it to show th "markers" (ignoring the clustering) would probably give you a reasonable result. How to do that is well documented: The Basics - Part 14 Fitting the map zoom to the data http://econym.org.uk/gmap/basic14.htm and there are lots of examples out there of how to do that, most of my maps do it. -- Larry > > Cheers, > > Neil > > My function to initialise the map is posted below: > > function load() { > if (GBrowserIsCompatible()) { > var map = new GMap2( > document.getElementById("map")); > map.addControl(new GSmallMapControl()); > map.addControl(new GMapTypeControl()); > map.addMapType(G_SATELLITE_3D_MAP); > map.setCenter( > new GLatLng(34.94148,-114.139431), 11); > var icon = new GIcon(G_DEFAULT_ICON); > icon.image = "http://chart.apis.google.com/chart? > cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png"; > var markers = [] > <!-- This function creates a marker for every lat/long in the query -- > > function createMarker(point, text, title) { > var marker = > new GMarker(point,{title:title}); > return marker; > } > > <?php > /* This is where all the data is collected into an array */ > $lat=array(); > $long=array(); > while($points = sqlsrv_fetch_array($result)) { > $lat[] = $points['gps_lat']; > $long[] = $points['gps_long']; > } > $latLongSize = sizeof($lat)-1; > > for($i=0; $i<=$latLongSize; $i++){ ?> > > markers.push(createMarker(new GLatLng(<?php echo $lat[$i];?>, <?php > echo $long[$i]; ?>))); > > <?php } ?> > > var markerCluster = new MarkerClusterer(map, markers); > } > } > //]]> > </script> -- You received this message because you are subscribed to the Google Groups "Google Maps API V2" 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.
