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

Dec 29, 2010 at 6:45 PM

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

 

Mase

 

mase@sumotext.com

Jan 27, 2011 at 3:01 PM

See other post: http://googlemap.codeplex.com/Thread/View.aspx?ThreadId=61576

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