GoogleMap 5...HELP!!! Markers, Center, Zoom

Dec 29, 2010 at 7:45 PM

I am using the 5.o version...I have a map with five markers added in to I auto center and zoom to fill all markers in....please help ASAP



Jan 27, 2011 at 4:01 PM

See other post:

Thanks to ryan_ca1, I was able to easily get this going...  First thing is to make sure you're getting your Min/Max Lat/Long (named ndMinLat, etc below)...

Also, I added it to the OnClientMapLoad rather than a separate call/function and fixed some little issues I found with his script (if your control isn't named map).  Just change "GoogleMap1" to your map id below and you're set!) have been fixed below in a VB version:


                Dim sbZoomMapScript As New StringBuilder
                With sbZoomMapScript
                    .AppendFormat("var sw = new GLatLng({0}, {1});", ndMinLat, ndMinLong).AppendLine()
                    .AppendFormat("var ne = new GLatLng({0}, {1});", ndMaxLat, ndMaxLong).AppendLine()
                    .AppendFormat("var bounds = new GLatLngBounds(sw, ne);").AppendLine()
                    .AppendFormat("var zoomLevel = {0}.GMap.getBoundsZoomLevel(bounds);", GoogleMap1.ClientID).AppendLine()
                    .AppendFormat("{0}.GMap.setZoom(zoomLevel);", GoogleMap1.ClientID).AppendLine()
                End With

                '\\ set the map to call zoomMap javascriptFunction
                Me.GoogleMap1.OnClientMapLoad &= sbZoomMapScript.ToString