从图像平铺生成器到Android Google Maps [英] Tile generator from an image to Android Google Maps

查看:127
本文介绍了从图像平铺生成器到Android Google Maps的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个问题,所以让我们向右移动

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

我有一张高分辨率png格式的地图,该地图具有四角的地理坐标,我想将其与Android App中的Google Maps Api集成.

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.

我到目前为止所做的事情:

  • 我已将地图切成256x256像素的图块,并编写了URITileProvider.事实证明,地图存在偏移,倾斜且必须重新调整大小

  • 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

我找到了 MapTiler 并进行了尝试.它允许设置拐角坐标并生成图块.当前的免费版本会产生水印,因此我也检查了以前的beta版本-但是在另一半球上放置了"y"图块坐标.当然,我可以尝试对其进行映射,但这并不能解决我的倾斜问题

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

我还找到了Android应用程序 CustomMaps .太棒了!它几乎完全符合我的要求,只是它不会生成图块.有一个选项可以拍摄图像文件,方法是从图像中选择点并将其链接到Google地图,然后将其放置在地图上.它还提供了一个很好的概述.

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.

这是我的问题:

是否有一个免费工具,结合了MapTiler和CustomMaps两种功能,可以用来对齐我的图像以映射并将其拆分为有效的图块?

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.

推荐答案

我已经设法解决了这个问题,并且我想与您分享. 我编写了自己的图块生成器.该解决方案肯定不是理想的,可能需要做更多的工作.欢迎任何贡献.

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. 使用Google地图,放大所需的区域,并粘贴到图形编辑程序中作为背景层.
  2. 将叠加层地图粘贴到另一层的图形程序中,然后对其进行转换以使其与背景中的地图匹配
  3. 使用Google地图尽可能精确地读取最大/最小纬度和经度
  4. 使用我的MapTileGenerator 生成图块.
  5. 在Android中使用 URITileProvider

  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;
}

我已经为该过程录制了一个简短的视频.可以在youtube上使用:地图图块生成器说明. 不幸的是,它用波兰语书写,但是在阅读了以上几点之后,消息应该很清晰.

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.

这篇关于从图像平铺生成器到Android Google Maps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆