How to display a custom map on Android [closed]

我们两清 提交于 2019-12-09 20:48:53

问题


I'm trying to make an Android application that displays a map of a Park and when a user taps on a certain location on the map, the application goes to another screen.

Problem is that currently my map of the park is in a .jpg format. Which mapping API is best for my application and how would I go about converting this .jpg map into a format that is accepted by the API.

Thanks!


回答1:


Adding an overlay for Google maps with a custom map is pretty easy to do, the sample code works out of the box.

To overlay the map you need to have a rough idea of the gps coordinates of the park. There is the sample code for overlays using a jpg is here: https://code.google.com/p/android-maps-extensions/source/browse/google-play-services-samples/src/com/example/mapdemo/GroundOverlayDemoActivity.java?r=fd7175206a82da6d87b773e968d52849b4c107fb

Clone the entire project and import it into Eclipse:

git clone https://code.google.com/p/android-maps-extensions/

After you have it running and installed on your device, you will want to get an API key here: https://code.google.com/apis/console

Full instructions are here if you get stuck: https://developers.google.com/maps/documentation/android/start

There are other demos to make your map more useful for example:

  • traffic info to get to the event/park
  • a 3D perspective if you want for eye candy
  • GPS of users current location with relation to the park
  • make the overlay opaque, or slightly transparent
  • custom markers so the user can tap and open another screen



回答2:


Well, you can use the google maps api v2 in android, and you create an Overlay map and implement the getTile, here you can find more info:

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/TileProvider

but the only thing is, change the properties in order that the maps ask for the tile you want to send, lest say that you have 4 tiles for your map, so use a zoom level that only allows 4 tiles to be delivered and then you return the corresponding tile to the map.

also you have to set the type map to NONE.



来源:https://stackoverflow.com/questions/19798797/how-to-display-a-custom-map-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!