I am new to the thinkgeo control, so I have a simple question.
How do I navigate to or center my wpf map on a given lat/long coordinate? I’m using the GoogleMapsOverlay
Navigate to lat/long coordinates
Hi Scott,
Thanks for your post, and welcome to MapSuite world! would you please use Map.CenterAt with following code?
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
Map1.MapUnit = GeographyUnit.Meter;
Map1.CurrentExtent = new RectangleShape(-5000000, 5000000, 5000000, -5000000);
GoogleMapsOverlay worldOverlay = new GoogleMapsOverlay();
Map1.CenterAt(new Feature(YourLongitude ,YourLatitude));
Map1.Overlays.Add("WMK", worldOverlay);
Map1.Refresh();
}
Another thing for your information is that Map1.ZoomIntoCenter() and Map1.ZoomOuttoCenter(), could not just centerat but also zoomin or out at same time.
if you have any more question , please feel free to let us know.
Best Regards
Summer
Thanks for the reply. I put that in, but when I put the coordinates in for the usa, it is showing africa and south america instead.
Hi Scott,
This should be because the lat and lon themselves don’t belong to google projection, so it needs a projection convertion. If the lat and lon belong to EPSG:4326 then would you please try following code:
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
ManagedProj4Projection proj = new ManagedProj4Projection();
proj.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);
proj.ExternalProjectionParametersString = ManagedProj4Projection.GetGoogleMapParametersString();
proj.Open();
Vertex projectedShape = proj.ConvertToExternalProjection(yourLongitude, yourLatitude);
Map1.MapUnit = GeographyUnit.Meter;
Map1.CurrentExtent = new RectangleShape(-5000000, 5000000, 5000000, -5000000);
GoogleMapsOverlay worldOverlay = new GoogleMapsOverlay();
Map1.CenterAt(new Feature(projectedShape));
Map1.Overlays.Add(“WMK”, worldOverlay);
Map1.Refresh();
}
if you have any more question , please feel free to let us know.
Best Regards
Summer