如何在Android应用中使用自己的自定义图像代替Google地图 [英] How to use own custom imagery instead of google map in Android app

查看:117
本文介绍了如何在Android应用中使用自己的自定义图像代替Google地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在android中开发了一个应用程序,正在使用Google Map捕获位置.我有一个较大的卫星图像(大于500 mb),此图像是地理编码.我们需要将其显示为地图中的图层之一,例如google map可以选择卫星图像.怎么做到呢. 预先谢谢你.

I have developed an app in android where I am using Google Map for capturing location. I have a large satellite image ( greater than 500 mb ), this image is geo-coded. We need to display this as one of the layers in the map like google map has a choice for satellite imagery. How can it be done. Thank you in advance.

推荐答案

要将自定义想象添加到地图中,可以使用TileOverlay:

To add custom imaginery to your map you can use TileOverlay:

来自TileOverlay

TileOverlay定义了一组添加到基本地图图块顶部的图像.您还可以使用图块叠加层通过提供透明的图块图像来向地图添加其他功能.您需要提供要支持的每个缩放级别的图块.如果您在多个缩放级别上有足够的图块,则可以为整个地图补充Google的地图数据.

A TileOverlay defines a set of images that are added on top of the base map tiles. You can also use tile overlays to add extra features to the map by providing transparent tile images. You need to provide the tiles for each zoom level that you want to support. If you have enough tiles at multiple zoom levels, you can supplement Google's map data for the entire map.

当您想向地图添加通常覆盖较大地理区域的大量图像时,拼贴图叠加层很有用.相反,当您希望将单个图像固定在地图上的一个区域时,地面叠加层很有用.

Tile overlays are useful when you want to add extensive imagery to the map, typically covering large geographical areas. In contrast, ground overlays are useful when you wish to fix a single image at one area on the map.

要使用TileOverlay,您需要实现一个TileProvider,它为地图请求的每个图块返回正确的Tile对象.

To use TileOverlay you need to implement a TileProvider that returns the correct Tile object for each tile requested by the map.

请注意,您的数据(您的图像)需要进行地理定位,以返回要在地图上绘制的正确图块.

Take into account that your data (your images) need to be georeferenced to return the correct tiles to be drawn on the map.

显示数据后,您可能需要执行map.setMapType(GoogleMap.MAP_TYPE_NONE);停止询问Google磁贴.

Once your data is displayed you may want to do map.setMapType(GoogleMap.MAP_TYPE_NONE); to stop asking for Google tiles.

根据评论进行更新:

您说要自动为不同的图像格式进行平铺时,需要为要加载的每种图像格式实现TileProvider.

As you say that you want to automate the tiling for different image formats, you will need to implement a TileProvider for each of the image formats that you want to be able to load.

要返回正确的Tile,您将需要在图块x,y和缩放(TileProvider界面的public Tile getTile(int x, int y, int zoom)函数的参数)与地理参考的坐标(和像素)之间转换图像.您可以查看 http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/以了解有关切片系统的更多信息.

To return the correct Tile you will need to transform between the tile x, y, and zoom (the parameters of the public Tile getTile(int x, int y, int zoom) function of the TileProvider interface) and the coordinates (and pixels) of you georeferenced image. You can take a look at http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ to learn more about the tiling system.

此外,如果图像的斜度不是WGS84,则需要对数据进行地理转换.

Also, if the image's srid not WGS84 you will need to geotransform your data.

请考虑到,如果您的图像很大,并且显示的区域很大,则可能会发现OutOfMemory错误,并且您可能希望查看

Take into account that if your image is big and you are showing a large area you may find OutOfMemory errors, and you may want to take a look at Loading Large Bitmaps Efficiently to load a scaled down version of your image to be returned as the tile.

这篇关于如何在Android应用中使用自己的自定义图像代替Google地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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