it is succeed,but I don’t need GeographyUnit.Meter,I need use GeographyUnit.DecimalDegree. Can you help me.
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
wpfMap1.MapUnit = GeographyUnit.Meter;
OpenStreetMapOverlay osmOverlay = null;
osmOverlay = new OpenStreetMapOverlay();
osmOverlay.IsVisible = true;
wpfMap1.Overlays.Add(“Open Street Map”, osmOverlay);
wpfMap1.CurrentExtent = new RectangleShape(-14136706, 6440000, -5649000, 952000);
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
OpenStreetMapOverlay osmOverlay = null;
osmOverlay = new OpenStreetMapOverlay();
osmOverlay.IsVisible = true;
wpfMap1.Overlays.Add(“Open Street Map”, osmOverlay);
wpfMap1.CurrentExtent = new RectangleShape(103.58,1.50,104.11,1.17);
}
it don’t show osm map. Can you help me to modify it?
Using osm map
Hi wang,
The OpenStreetMapOverlay supports projection, would you please try the below codes to do the projection conversion?
Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
proj4.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
proj4.Open();
OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay();
osmOverlay.ProjectionFromSphericalMercator = proj4;
Any other questions, don’t hesitate to let us know.
Thanks,
Troy
Hi Troy,
Can you help me?
I have a problem, I already init a osm map,and add a button in the map ,order to realize that :
if cilck button can draw a rectangle( only draw one rectangle) to set currentextent in the map, Like “Shift” + draw a rectangle function.
how to reallize,I know:
this.wpfMap1.TrackOverlay.TrackMode = TrackMode.Rectangle; // it can draw a rectangle,but it can draw a lot of rectangle.Don’t i need.
1. how to get the rectangle?
2. how to set currentextent? like “this.wpfMap1.CurrentExtent = rectangle.GetBoundingBox();”? this’s true?
Hi Burning,
Would you please try the below codes:
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
wpfMap1.CurrentExtent = new RectangleShape(-133.2515625, 89.2484375, 126.9046875, -88.290625);
WorldMapKitWmsWpfOverlay worldMapKitOverlay = new WorldMapKitWmsWpfOverlay();
wpfMap1.Overlays.Add(worldMapKitOverlay);
wpfMap1.TrackOverlay.TrackEnded += TrackOverlay_TrackEnded;
wpfMap1.Refresh();
}
void TrackOverlay_TrackEnded(object sender, TrackEndedTrackInteractiveOverlayEventArgs e)
{
wpfMap1.TrackOverlay.TrackMode = TrackMode.None;
wpfMap1.CurrentExtent = wpfMap1.TrackOverlay.TrackShapeLayer.InternalFeatures[0].GetBoundingBox();
}
Hope it helps and any questions, please let us know.
Thanks,
Troy