Good morning all,

 

I'm looking for some advice on how to have a map centre itself and zoom
based on the markers which are on the map. I basically want the map to load
so that you can see all the markers, zoomed in and cantered as best possible
so that no markers are outside of the visible bounds to start with, Is this
possible? Has anyone got some working examples of this?

 

My current code looks something like this:

 

    <script type="text/javascript">

            $(document).ready(function() {

                  load();

            });

          //<![CDATA[

          function load() {

            if (GBrowserIsCompatible()) {

              var map = new GMap2(document.getElementById("map"));

              map.setCenter(new GLatLng(37.4419, -122.1419), 13);

              

              var mapControl = new GMapTypeControl();

              map.addControl(mapControl);

              map.addControl(new GSmallMapControl());

              

                  function createMarker(point)

                  {

                  var marker = new GMarker(point);

                  GEvent.addListener(marker, "click", function() {

                        var myHtml = "This is a mesage";

                        map.openInfoWindowHtml(point, myHtml);

                  });

                  map.addOverlay(marker);

                  }

              

              var point = new GLatLng(37.4419, -122.1419);

              createMarker(point);

            }

          }

          //]]>

    </script>

 

I really appreciate your advice on this guys,

 

Thanks,

 

Heston


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to