I am converting v2 code to v4. I am trying to display the current position (supplied via GPS) and zoom in to display it. Previously I used MapShape to do this so the code needs a complete re-write.
I have come up with this to display the position:
InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
PointShape currentPos = new PointShape(gpsPosition.Easting, gpsPosition.Northing); inMemoryLayer.InternalFeatures.Add("Position", new Feature(currentPos));
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Star, new GeoSolidBrush(GeoColor.StandardColors.Red), new GeoPen(GeoColor.StandardColors.Black), 14);
Next I want to zoom in. Previously I used this code:
Dim ell As Ellipse = currentPos.Buffer(100, MapLengthUnits.metres, MapLengthUnits.metres) Dim rect As StraightRectangle = ell.Envelope rect.ScaleUp(100) Map1.CurrentExtent = rect.ToRectangleR
But .Buffer now returns a MultipolygonShape not an ellipse. What is the best way to do this?
First I want to let you know that we created a sample just to follow the functionality of MapShapes existing in MapSuite 2.x version. code.thinkgeo.com/projects/show/mapshapes
The code shown using the InmemoryFeatureLayer is exactly what we are going to do in MapSuite 4.x, that is it, you are perfectly right.
About the MultipolygonShape instead of ellipse shape, I am not sure why you want to get is an ellipse shape instead of a MultipolygonShape, in fact, the ellipse shape itself is a Polygonshape with multiple points to looks like an ellipse. If we really want to get an ellipse shape instead of a MultipolygonShape, follow following steps to convert it: Step1: Get the boundingBox of the multipolygonShape. Step2: Get the width and height of the boundingbox. Step3: Get the center of the boundingbox. Step4: Create an ellipse with the width, height, center.