This project is read-only.

Adding a simple dot or line on the map (using mapwingis)

Jan 23, 2015 at 8:15 PM
Edited Jan 23, 2015 at 8:16 PM
Hi there,

I just started with MapWinGIS activex control in vb express 2010.

showing google maps or openstreetmaps etc goes well, I use following code:
AxMap1.Projection = MapWinGIS.tkMapProjection.PROJECTION_GOOGLE_MERCATOR
    AxMap1.TileProvider = MapWinGIS.tkTileProvider.GoogleHybrid
    AxMap1.KnownExtents = MapWinGIS.tkKnownExtents.keNetherlands
    AxMap1.Tiles.DoCaching(MapWinGIS.tkCacheType.Both) = True
    AxMap1.Tiles.UseCache(MapWinGIS.tkCacheType.Both) = True
Then I want to add some lines and dots on this map, coming from measurements we did,
I use following code:
Dim DrawingLayerHandle As Integer
    DrawingLayerHandle = Map.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList)
    Map.DrawCircleEx(DrawingLayerHandle, Longitude, Latitude, 1000000, System.Convert.ToUInt32(RGB(255, 0, 0)), True)
With every longitude and latitude I use, the circle is drawed at coordinages 0;0 ?

I tried other things like loading a KML file with the same result, the kml coordinates are being ignored and the figure is drawed around coordinates 0,0;
Code:
  Dim filename = "c:\klad\maps\example.kml"
  AxMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosAutoDetect, True)
  AxMap1.Refresh()
Example kml:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Paths</name>
<description>Examples of paths. Note that the tessellate tag is by default
  set to 0. If you want to create tessellated lines, they must be authored
  (or edited) directly in KML.</description>
<Style id="yellowLineGreenPoly">
  <LineStyle>
    <color>7f00ffff</color>
    <width>4</width>
  </LineStyle>
  <PolyStyle>
    <color>7f00ff00</color>
  </PolyStyle>
</Style>
<Placemark>
  <name>Absolute Extruded</name>
  <description>Transparent green wall with yellow outlines</description>
  <styleUrl>#yellowLineGreenPoly</styleUrl>
  <LineString>
    <extrude>1</extrude>
    <tessellate>1</tessellate>
    <altitudeMode>absolute</altitudeMode>
    <coordinates> 
        4.8951679,52.3702157
        5.5951679,52.2702157
        6.1951679,52.1702157
        4.8951679,52.3702157
    </coordinates>
  </LineString>
</Placemark>
</Document>
</kml>


Anyone can help?

Thanks!
Jan 24, 2015 at 8:33 AM
Edited Jan 24, 2015 at 8:34 AM
It seems that you are not reprojecting coordinates. Your map project is spherical Mercator (in meters) while you are passing coordinates as degrees.

You should use AxMap.DegreesToProjection method (see Adding markers to the map here).

For vector layers (KML) automatic reprojection can be set up, see "Improved API for projection mismatch testing" here.

It's also possible to do reprojection of any data manually via GeoProjection class (StartTransform, Transform, StopTransform).

However the easiest option for you is to set WGS84 equirectangular projection (AxMap.Projection = tkMapProjection.PROJECTION_WGS84). Background tiles will be somewhat scaled then, but your data won't need transformation.

Regards,
Sergei