I am adding a marker move feature to our test app so a user can correct the Lat & Lon of an address that is not accurate. So in my example when I search for the address it returns one result and shows the marker. (Coordinates are 40.983363, -74.305872)
So the first problem I noticed is when I search for the same coordinates on OpenStreetMaps It does not show in the same spot. (See Below)
Moving on… So now I want to drag the pin to the new location. I drag it and when it is dropped the coordinates are updated as (40.983464, -74.307388) and an the pin is showing here (See below)
Now if I take this new coordinates and pop them into OpenStreetMaps you can see the pin location differs drastically from what is shown in the application.
Why is this occurring? There is certainly no way I can put out a feature like this that is so inaccurate.
The code for loading our map is pretty basic.
01.
mapCtrl.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
02.
mapCtrl.MapResizeMode = MapResizeMode.PreserveScaleAndCenter
03.
04.
mapCtrl.MapUnit = GeographyUnit.DecimalDegree
05.
mapCtrl.BackgroundOverlay.BackgroundBrush =
New
GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)
06.
mapCtrl.CurrentExtent =
New
RectangleShape(-75.412903, 41.409776, -73.979187, 38.826871)
07.
08.
simpleMarkerOverlay =
New
SimpleMarkerOverlay()
09.
simpleMarkerOverlay.MapControl = mapCtrl
10.
11.
simpleMarkerOverlay.DragMode = MarkerDragMode.Drag
12.
13.
mapCtrl.Overlays.Add(
“WMK”
,
New
WorldMapKitWmsDesktopOverlay())
14.
mapCtrl.Overlays.Add(
“SimpleMarker”
, simpleMarkerOverlay)
15.
16.
mapCtrl.Refresh()
For the coordinates after the drag we are handling the MarkerDragged Event.
1.
Private
Sub
simpleMarkerOverlay_MarkerDragged(sender
As
Object
, e
As
MarkerDraggedSimpleMarkerOverlayEventArgs)
Handles
simpleMarkerOverlay.MarkerDragged
2.
Dim
mouseLocation
As
PointShape = ExtentHelper.ToWorldCoordinate(mapCtrl.CurrentExtent,
New
ScreenPointF(e.CurrentLocation.X, e.CurrentLocation.Y), mapCtrl.Width, mapCtrl.Height)
3.
If
DevExpress.XtraEditors.XtraMessageBox.Show(
“Do you want to store the new Latitude and Longitude for this location?”
& vbCrLf &
String
.Format(CultureInfo.InvariantCulture,
“Lat :{0:0.######}”
, mouseLocation.Y) & Space(1) &
String
.Format(CultureInfo.InvariantCulture,
“Lon: {0:0.######}”
, mouseLocation.X),
“Correct Location?”
, MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes
Then
4.
'Store to Data Source
5.
Me
.txtLatitude.EditValue = mouseLocation.Y
6.
Me
.txtLongitude.EditValue = mouseLocation.X
7.
End
If
8.
End
Sub