none
Mercator projection using Image control in wpf RRS feed

  • Question

  • Hi folks,

    Im trying to make some simple app. Only for personal purposes. I have WPF app, in which I have Image control of size 300x300. I use bing maps api to get the image(map). The returned image is inserted into the Image control. Everything works fine. Now I want to do: When I click on the map, I would like to get coordinates (lat, long) of the place, where I've clicked. I read some articles about Mercator projection, but I dont know, how to use it. Do I need to transform mouse position to mercator coordinates and then transform it to the Lat and Long? I've tried algorithm from bing websites and as X and Y parameters I insterted mouse posiition X, Y. But it doesnt work. 

    Thank you for some help.

    Saturday, November 28, 2015 2:37 PM

Answers

  • Give us a chance. You asked your question on Saturday, it was a national holiday weekend. Note, we answer questions in our spare time because we want to help the developer community, this isn't part of our job.

    As for your question, you can find documentation on how the tiling system works in Bing Maps here: https://msdn.microsoft.com/en-us/library/bb259689.aspx This has the calculations you need to georeferenced an image and connect pixels to their relative latitude/longitude values. This assumes you are getting an image you know the zoom level for. If you just have a random image, then you need to know a couple of reference points at a minimum so you can georeferenced your image. I have a really old code sample that shows how to georeferenced an image from the Bing Maps (formerly known as Virtual Earth) SOAP services: https://rbrundritt.wordpress.com/2008/10/25/ve-imagery-service-and-custom-icons/

    If you are getting your image from the Bing Maps REST imagery service and you are drawing pushpins on your image and want to make those clickable via an HTML image map, the imagery service has a metadata option which returns the pixel coordinates of the pushpins which you can use to build an HTML image map.


    http://rbrundritt.wordpress.com

    Monday, November 30, 2015 5:36 PM

All replies

  • Nobody?
    Sunday, November 29, 2015 4:00 PM
  • Give us a chance. You asked your question on Saturday, it was a national holiday weekend. Note, we answer questions in our spare time because we want to help the developer community, this isn't part of our job.

    As for your question, you can find documentation on how the tiling system works in Bing Maps here: https://msdn.microsoft.com/en-us/library/bb259689.aspx This has the calculations you need to georeferenced an image and connect pixels to their relative latitude/longitude values. This assumes you are getting an image you know the zoom level for. If you just have a random image, then you need to know a couple of reference points at a minimum so you can georeferenced your image. I have a really old code sample that shows how to georeferenced an image from the Bing Maps (formerly known as Virtual Earth) SOAP services: https://rbrundritt.wordpress.com/2008/10/25/ve-imagery-service-and-custom-icons/

    If you are getting your image from the Bing Maps REST imagery service and you are drawing pushpins on your image and want to make those clickable via an HTML image map, the imagery service has a metadata option which returns the pixel coordinates of the pushpins which you can use to build an HTML image map.


    http://rbrundritt.wordpress.com

    Monday, November 30, 2015 5:36 PM