Map coordinates

8/11/2016 8:58:14 AM
Total Posts 19

Map coordinates

Hi

Is there a way that I can extract the current x/y/zoom coordinates without the user having to click on the map?

Are there continually updated variables that I can use that don't rely on the user clicking?

Cheers

Dave

8/12/2016 6:28:35 AM
Total Posts 19

Re: Map coordinates

OK, I have found map1.mapscale which appears to hold the current zoom level, but anyone got any ideas about where to find the current Latitude and longitude as map1. doesnt have either

Cheers

Dave

8/13/2016 5:07:39 AM
MVP
Total Posts 323

Re: Map coordinates

The current scale of the map can be obtained via the Map.MapScale property, and the center of the map via the Map.Extent.Center property.

3/3/2017 7:15:31 AM
Total Posts 19

Re: Map coordinates

OK, revisiting this again - using windows forms - can I extract the latitude and longitude of the map.extent?

3/7/2017 1:43:34 PM
MVP
Total Posts 323

Re: Map coordinates

This depends on the map data, if the map units are decimal degrees, the lat/long coordinates are as follows:

latitude = extent.Top
longitude = extent.Left

latitude = extent.Bottom
longitude = extent.Right

If the map units are not decimal degrees, you have to transform the extent to a lat/long extent first:

latLongExtent = map.CoordinateSystem.ToWgs84(map.Extent);

latitude = latLongExtent.Top
longitude = latLongExtent.Left

 

 

3/9/2017 9:50:05 AM
Total Posts 19

Re: Map coordinates

Hi

Having spoken to our map provider (Cyient UK), giving him the coordinates for a position in actualMap of Canterbury (UK) Cemetery - x = 618078.04438004922 and y =16681.54704490988, he would expect :

For a location near the entrance of Canterbury (UK) Cemetery, I would expect:
1. For Easting / Northing values: X=613709, Y=158352
2. For Longitude/Latitude values (OSGB Projection): X=1.064939, Y=51.283642
2. For Longitude/Latitude values (WGS84): X=1.063207, Y=51.284198

Is the Easting/Northing coordinates in Actualmap just the left hand side of the point or is that a coincidence?

When I use your code:
Public latlongExtent As ActualMap.Rectangle
latlongExtent = Map1.CoordinateSystem.ToWgs84(Map1.Extent)
I get a Nul Reference exception

Can you give me some way of reconciling your values with his please?

Cheers

Dave

3/14/2017 11:07:57 AM
MVP
Total Posts 323

Re: Map coordinates

If a null reference exception is returned, then Map1.CoordinateSystem was not set to the coordinate system of your maps(which is probably http://spatialreference.org/ref/epsg/osgb-1936-british-national-grid/)

AspMap.CoordSystem mapCS = new AspMap.CoordSystem(CoordSystemCode.PCS_OSGB1936BritishNationalGrid);

latLongExt = mapCS.ToWgs84(map.Extent);

latitude = latLongExt.Top;     // Y
longitude = latLongExt.Left;  // X