Android: How To: mark the current location into a map (still image) - SOURCE CODE,TESTCASE,ACTUAL,EXPECTED OUTPUT ADDED

后端 未结 1 1022
耶瑟儿~
耶瑟儿~ 2020-12-22 08:10

I have created another question (How to display a map (still image file) with a moving current location)

But it contains 2 (two) questions, so i need to segregate it

相关标签:
1条回答
  • 2020-12-22 08:33

    From what I understood, you are facing a few problems here.

    • Use a map controller with offline tiles

    • Mark the current location on the map

    • Route the user from point A to point B


    Map controller

    Basically, the location providers on Android will be feeding your application with some global positioning coordinates (longitude and latitude) and you want to put a background behind it so that the user has a visual on his location. Your idea to put a still image there is right, but a correction I would suggest (and this is the way it works on every commercial, or non-commercial, product) is to split the large images into smaller parts, so that the map controller wouldn't have to load a large image into memory. 512 x 512 sounds like a reasonable size (Google maps uses 256 x 256). These chunks of larger images are called tiles.

    With Google maps it's impossible to use offline tiles. I've written a post on how to do that for Google maps with OSMDroid (this is the best open source alternative) and another post with ArcGIS (free map controller for Android, commercial map tiles; everything is awesome with this controller but in my opinion it's too loaded for a thesis project).

    So, the steps to reproduce here are:

    • chunk big files into smaller parts
    • find the exact coordinates of the edges of your big images to know exactly how to name the tiles (map controllers find tiles required to cover a portion of the viewport by names)
    • implement an offline tile provider with your images

    Location provider

    This, in my opinion is the hardest part. How exactly are you going to find the exact position of a device in a building? GPS can be of a help to a certain extent, but it can't be precise in a building anyway. ArcGIS provides you with a very nice built-in location provider, on any other solution you'll have to implement it on your own. As soon as you manage to overcome this problem you can also use the altitude provided by the location providers to switch between the floors automatically.

    Routing

    To represent a routing line with OSMDroid (well, with ArcGIS as well) is a piece of chocolate cake: create an array of turn points, draw a line from one point to another and put that line on the map. The hard part is to create a routing algorithm, good luck with that!

    0 讨论(0)
提交回复
热议问题