none
Getting the top left and bottom right latitude and longitude RRS feed

  • Question

  • As the title says, I want the top-left and bottom-right latitude and longitude that is currently being displayed on a VEMap.

    I want to change some information on the zoom event and changing the zoom will result in changing the top-left and bottom-right latitude and longitude. Is there anyway to get this information.

    Also I know that there is GetCenter() function that provides the center point latitude and longitude.

    Thank you

    Monday, July 1, 2013 5:50 PM

Answers

  • Hi,

    you can do that using the getBounds API:

    var bounds=map.getBounds(); 
    displayAlert('Map bounds: ' +  bounds);


    Viktor Halitsyn

    Monday, July 1, 2013 9:30 PM
  • Thanks for the reply but there is no such method available.

    This is what I was looking for:

    var bounds = map.GetMapView();
    alert("Map bounds: " + bounds.BottomRightLatLong + " -- " + bounds.TopLeftLatLong);
    


    • Marked as answer by RezaHT Tuesday, July 2, 2013 5:08 PM
    • Edited by RezaHT Tuesday, July 2, 2013 5:08 PM changes
    Tuesday, July 2, 2013 5:08 PM
  • You really don't want to use the pixel-to-latlong method. It only produces valid results for ortho Mercator views. It's much more robust to use the supported bounds method which will always work.
    Tuesday, July 2, 2013 7:38 PM
    Moderator

All replies

  • Hi,

    you can do that using the getBounds API:

    var bounds=map.getBounds(); 
    displayAlert('Map bounds: ' +  bounds);


    Viktor Halitsyn

    Monday, July 1, 2013 9:30 PM
  • Thanks for the reply but there is no such method available.

    This is what I was looking for:

    var bounds = map.GetMapView();
    alert("Map bounds: " + bounds.BottomRightLatLong + " -- " + bounds.TopLeftLatLong);
    


    • Marked as answer by RezaHT Tuesday, July 2, 2013 5:08 PM
    • Edited by RezaHT Tuesday, July 2, 2013 5:08 PM changes
    Tuesday, July 2, 2013 5:08 PM
  • There is also another non-standard way of getting these values:

    var TopLeftLatLong = map.PixelToLatLong(new VEPixel(0, 0));
    var BottomRightLatLong = map.PixelToLatLong(new VEPixel(this.mapWidth, this.mapHeight));
    alert(TopLeftLatLong + " -- " + BottomRightLatLong);


    Tuesday, July 2, 2013 5:13 PM
  • You really don't want to use the pixel-to-latlong method. It only produces valid results for ortho Mercator views. It's much more robust to use the supported bounds method which will always work.
    Tuesday, July 2, 2013 7:38 PM
    Moderator