I have geometry data in decimal/degree. I use the following code to create plygon features in meters and show on Bing:
01.Collection<Feature> GeometrySource =newCollection<Feature>();02.03.Proj4Projection wgs84ToBingProjection =newProj4Projection();04.wgs84ToBingProjection.InternalProjectionParameters = Proj4Projection.GetWgs84ParametersString();05.wgs84ToBingProjection.ExternalProjectionParameters = Proj4Projection.GetBingMapParametersString();06.07.mapView.MapUnit = GeographyUnit.Meter;08.09.//add polygon geometry from decimal to meter10.var wkt =“MULTIPOLYGON (((153.524037 -28.498472, 153.523862 -28.498368, 153.523872 -28.498313, 153.522815 -28.49754, 153.522267 -28.497456, 153.522085 -28.497335, 153.52199 -28.496912, 153.521821 -28.496851, 153.521158 -28.496832, 153.520307 -28.496703, 153.519958 -28.495789, 153.519853 -28.495047, 153.520196 -28.49465, 153.51935 -28.49412, 153.518921 -28.494059, 153.518301 -28.493425, 153.518185 -28.493528, 153.518079 -28.493408, 153.517854 -28.493586, 153.516154 -28.495845, 153.515681 -28.496111, 153.515611 -28.496495, 153.515958 -28.497056, 153.515952 -28.497245, 153.515541 -28.497192, 153.515151 -28.499144, 153.515572 -28.498816, 153.516452 -28.499015, 153.516862 -28.498971, 153.516972 -28.498986, 153.51762 -28.499208, 153.517913 -28.499438, 153.516892 -28.499142, 153.516472 -28.499215, 153.515602 -28.499017, 153.51511 -28.499395, 153.514964 -28.500276, 153.515872 -28.500527, 153.516602 -28.500785, 153.518452 -28.501494, 153.519034 -28.501611, 153.518397 -28.505074, 153.522304 -28.505621, 153.523145 -28.500816, 153.523428 -28.500727, 153.523604 -28.499773, 153.523288 -28.499487, 153.523127 -28.499221, 153.522288 -28.499088, 153.522007 -28.498937, 153.521256 -28.499067, 153.520954 -28.498921, 153.520459 -28.498929, 153.519935 -28.499166, 153.518793 -28.499317, 153.518742 -28.499156, 153.519872 -28.498996, 153.52001 -28.498945, 153.520416 -28.498749, 153.520994 -28.498739, 153.521282 -28.498878, 153.522006 -28.498734, 153.522368 -28.498909, 153.523262 -28.499055, 153.523218 -28.498984, 153.523419 -28.49846, 153.523832 -28.498522, 153.524037 -28.498472)), ((153.528358 -28.505154, 153.528186 -28.504247, 153.528127 -28.5042, 153.527784 -28.504181, 153.52791 -28.505227, 153.528056 -28.505199, 153.528358 -28.505154)))”;11.wgs84ToBingProjection.Open();12.BaseShape poly =newMultiPolygonShape(wkt);13.Faeature f =newFeature((PolygonShape)wgs84ToBingProjection.ConvertToExternalProjection(poly));14.GeometrySource.Add(f);15.wgs84ToBingProjection.Close();16.17.//set extent18.wgs84ToBingProjection.Open();19.RectangleShape mapExtent = (RectangleShape)ExtentHelper.GetBoundingBoxOfItems(GeometrySource).CloneDeep();20.mapExtent = wgs84ToBingProjection.ConvertToExternalProjection(mapExtent);21.wgs84ToBingProjection.Close();22.mapView.CurrentExtent = mapExtent;23.mapExtent.ScaleUp(100);24.25.//Keep geometry feature in InMemoryFeatureLayer26.var SourceFeatureLayer =newInMemoryFeatureLayer();27.SourceFeatureLayer.Open();28.SourceFeatureLayer.Columns.Add(newFeatureSourceColumn(“Name”));29.30.SourceFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle =newAreaStyle(newGeoSolidBrush(BrushColor));31.SourceFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.SimpleColors.Black;32.SourceFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;33.SourceFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle =newTextStyle(“Name”,newGeoFont(“Arail”, 9, DrawingFontStyles.Bold),newGeoSolidBrush(GeoColor.SimpleColors.Black));34.SourceFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.SecondaryRoad2;35.36.foreach(Feature featureinGeometrySource)37.{38.SourceFeatureLayer.InternalFeatures.Add(feature);39.}40.41.//create bing overlay as base42.var bingKey =“Bing Key here”;43.BingMapsOverlay bingMapOverlay =newBingMapsOverlay(“Agtrix”, bingKey, BingMapsStyle.Hybrid);44.bingMapOverlay.BingMapsStyle = BingMapsStyle.Hybrid;45.mapView.Overlays.Add(“bing”,bingMapOverlay);46.47.//add feature overlay which should display polygon on Bing map48.LayerOverlay layerOverlay =newLayerOverlay();49.layerOverlay.Layers.Add(“SourceLayer”, SourceFeatureLayer);50.mapView.Overlays.Add(“LayerOverlay”, layerOverlay);
This code works well in android but in WP the geometry are displayed off target (as shown in the snapshot attached…May I know what’s wrong? or Can you produce a sample code to achieve this?
Note the geometry is of the form: “MULTIPOLYGON (((153.524037 -28.498472, 153.523862 -28.498368,…”.
And by the way, why is the map a white area on certain zoom level? See another file attached.
off-target-geom-wp-white.png (22.8 KB)
off-target-geom-wp.png (46.5 KB)