Hi There,
I am having an issue with trying to zoom to and center on a unit on a map.
I am doing this by just giving a Lat & Lon. It seems to center horizontally
but does not seem to place the marker position properly vertically to center.
What am I doing wrong?
Thanks in advance.
Bob
’** Lat & Lon from dataview in Decimal Degrees
Dim dLat As Double = dv.Item(0).Item(“Lat”)
Dim dLon As Double = dv.Item(0).Item(“Lon”)
’** Convert Decimal Degrees to meters
ProjectVehicles2(dLon, dLat)
’** Zoom code
Dim f As New ThinkGeo.MapSuite.Core.PointShape
f.X = dLon 'dv.Item(0).Item(“Lon”)
f.Y = dLat 'dv.Item(0).Item(“Lat”)
Map1.ZoomTo(f, Map1.ClientZoomLevelScales(15))
Private Sub ProjectVehicles2(ByRef Lon As Double, ByRef Lat As Double)
If DirectCast(Session(“MapTypeObj”), MapType).MapProvider <> MapProvider.WorldMapKit Then
Dim proj4 As New Proj4Projection(Proj4Projection.GetEpsgParametersString(4326), Proj4Projection.GetGoogleMapParametersString())
proj4.Open()
Dim vertex As Vertex = proj4.ConvertToExternalProjection(Lon, Lat)
Lon = vertex.X
Lat = vertex.Y
proj4.Close()
End If
End Sub
ZoomTo Method - Doesn't center vertically?
We have a series of projects in the Code Community that deal with centering properly the map to a fixed point in Lat/Long or a moving vehicle. I don't know what your case is exactely, but I think that one of those projects should give you the solution to you problem.
-Center Map Based On Lat/Long code.thinkgeo.com/projects/show/centermapbasedonlat
-Centering and Rotating code.thinkgeo.com/projects/show/centeringrotating
-Centering Map with Tolerance code.thinkgeo.com/projects/show/centeringtolerance
-Centering On Moving Vehicle code.thinkgeo.com/projects/show/centeringonmoving
Hi Val,
Thanks for the examples. I just don’t understand why it is necessary to create a rectangle on a map layer and then add that layer to a map.
It seems a lot more complicated than it needs to be! Why is it not possible to simply use the ZoomTo command to center on a unit? I would assume that ZoomTo would center on the unit just by its very name.
Bob
Hi Bob,
I tried your code but unable to recreate the issue. Can you check the attached demo based on your code?
In the demo, the markerOverlay just contains one marker to present the center of the map. The marker’s position is the same to the center position used in Button_click method to zoom to. You can click the button to zoom into the center, and then click +/- on the PanZoomBar to zoom out/in to check whether the center changes a bit.
Thanks,
Johnny
001_Markers.zip (2.61 KB)