Tile generator from an image to Android Google Maps

耗尽温柔 提交于 2019-12-07 08:27:36

问题


This is my 1st question here, so lets move right to the point

I have a map in high resolution png format with geographic coordinates of the corners which I would like to integrate with Google Maps Api in my Android App.

What i have done so far:

  • I have cut the map in tiles 256x256 px and wrote an URITileProvider. It turns out that the map has an offset, is tilted and has to be re-sized

  • I found MapTiler and tried it out. It allows to set the corners coordinates and generates tiles. The current free version produces a watermark, so I have also checked the previous beta versions - but there the "y" tile coordinate is placed on the other hemisphere. Of course i could try to map them, but it doesn't solve my tilt problem

  • I also found and Android app CustomMaps. It is awesome! It does almost exactly what i want except it does not generate tiles. There is an option to take an image file, put it on the map by selecting points from the image and linking them to google map. It also provides a nice overview.

So here is my question:

Is there a free tool which combines both functionality form MapTiler and CustomMaps that I could use to align my image to map and split it into valid tiles?

I thought about editing the source image and by trial-and-error method, but it is definitely not the way to go here. Currently I'm thinking of creating my own tool, but logically thinking there has to be already a solution out there.


回答1:


I have managed to solve this problem and I've thought that I would share it with you. I wrote my own tile generator. The solution surely is not ideal and could need a lot more work. Any contributions are welcome.

Here are the steps to make it work:

  1. Use Google Maps, zoom in on the desired area, paste into graphic editing program as a background layer.
  2. Paste your overlay map into the graphic program on another layer and transform it to match the map in background
  3. Using Google maps read as precisely as possible the max/min latitude and longitude
  4. Use my MapTileGenerator to generate the tiles.
  5. In Android use URITileProvider

    @Override
    public URL getTileUrl(int x, int y, int zoom) {
    
        String url = MAP_FILES_URL + x + "-" + y + "-" + zoom + ".png";
        try {
            return new URL(url);
        } catch (MalformedURLException e) {
            // ignore
        }
        return null;
    }
    

I have recorded a short video for the process. It is available on youtube: Map Tile Generator Instructions. Unfortunately it is in polish, but the message should be pretty clear after reading the points above.

I am well aware that the script i wrote has problems with memory management and should use introduce multithreading. I hope i can get back to it any time soon.



来源:https://stackoverflow.com/questions/19607827/tile-generator-from-an-image-to-android-google-maps

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