-1

I get a lat long from the backend and I want to use a PNG as a map, because this map is self made. So I want to transfer my lat long on this PNG and then draw at this position a point, but I couldn't figure it out how to do... I couldn't find it here in another question. Maybe it's so easy that no one ever asked this.

I am new to Android and new to stackoverflow :)

EDIT because of comment: The image is a self made map. It was made with ESRI cityengine and Blender. Then I made a birdseye-screenshot of the map and this screenshot I want to use as my map.

EDIT 2: @MarkusKauppinen made a good comment! So I also want to convert the lat/long to x/y coordinates of the screen (like (How do android screen coordinates work?) ). But the lat/long of my backend don't relate to the lat/long of the Earth.

Community
  • 1
  • 1
Tobsmaster
  • 11
  • 5
  • It's not very clear from your question what you want. Do you want an image of Google Map with your lat,lng on it? Then you can try https://developers.google.com/maps/documentation/static-maps/intro – Sharjeel Mar 17 '17 at 16:21
  • The image is a self made map. It was made with ESRI cityengine and Blender. Then I made a birdseye-screenshot of the map and this screenshot I want to use as my map. – Tobsmaster Mar 17 '17 at 16:25
  • Use a Custom TileProvider in Google Maps for Android: http://stackoverflow.com/q/14784841/295004 and https://developers.google.com/maps/documentation/android-api/tileoverlay – Morrison Chang Mar 17 '17 at 16:44
  • Of course you can draw points on that map yourself. Has little to do with Android. Just calculate some x,y values. Thats all. – greenapps Mar 17 '17 at 17:02
  • Is the problem [converting lat/lon to x/y coordinates?](http://mathforum.org/library/drmath/view/51833.html) The link explains the necessary math. (Probably accurate enough for this purpose.) – Markus Kauppinen Mar 17 '17 at 18:46
  • All thx for your comments! Appreciate it alot! @MorrisonChang Could you tell me if this Tileprovider works without integrating the map of googlemaps? – Tobsmaster Mar 18 '17 at 18:15
  • @greenapps would you do it with a Canvas? – Tobsmaster Mar 18 '17 at 18:16
  • @MarkusKauppinen Thanks I edited my question because of your comment. See EDIT 2. So I want to convert the lat/long to x/y coordinates of the screen (like [link] (http://stackoverflow.com/questions/11483345/how-do-android-screen-coordinates-work) ). But the lat/long of my backend don't relate to the lat/long of the Earth. – Tobsmaster Mar 18 '17 at 18:16
  • Your map has a resolution in pixels. WxH. You should first, given a lat,lon, calculate an x,y in pixels for your map. If you are ready with that then you can try to display the map and convert map x,y to screen x,y. – greenapps Mar 18 '17 at 18:26
  • @greenapps thx i will try! – Tobsmaster Mar 18 '17 at 19:39

1 Answers1

0

Even thought that this question has a downvote and probably no one will ever see it, I could figure it out how to solve my problem. I used this Canvas Bitmap Method to draw the map on my screen. Then I converted the lat/long coordinates so that they fit on the Screen of the mobile phone with the help of this post: How do android screen coordinates work? With the converted lat/long coordinates then I could draw a circle on the current position on the map. Now when the coordinates change the circle is moving like it should.

Community
  • 1
  • 1
Tobsmaster
  • 11
  • 5