在谷歌地图Android版中的瓷砖图片 [英] Images tile on Google map in android
问题描述
我开发一个Android应用程序,我对谷歌地图Android版中的形象到位瓷砖。
I am developing an android application where I have place image tiles on Google map in android.
我可以用简单的JavaScript做,但谁能告诉我怎么做这是android.Here我的JavaScript code。
I can do with simple javascript but can anyone tell how I do this in android.Here is my JavaScript code.
function initialize() {
var center = new google.maps.LatLng(37.4419, -122.1419);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var globalfoovar = new google.maps.ImageMapType({
getTileUrl: function(tile, zoom) {
return "http://demoserver.com";
},
tileSize: new google.maps.Size(256, 256),
opacity:0.60,
isPng: true
});
map.overlayMapTypes.push(null); // create empty overlay entry
map.overlayMapTypes.setAt("0",globalfoovar); // set the overlay, 0 index
可以任意转换以上至Android谷歌地图。
Can any translate the above to android Google map.
由于android系统
Thanks in android
阿尔塔夫
推荐答案
现在是与地图API V2可能的,这里要说的是自带的API的例子:
It is now possible with the map api v2, here is an example that comes with the api :
private void setUpMap() {
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
TileProvider tileProvider = new UrlTileProvider(256, 256) {
@Override
public synchronized URL getTileUrl(int x, int y, int zoom) {
// The moon tile coordinate system is reversed. This is not normal.
int reversedY = (1 << zoom) - y - 1;
String s = String.format(Locale.US, "http://mw1.google.com/mw-planetary/lunar/lunarmaps_v1/clem_bw/%d/%d/%d.jpg", zoom, x, reversedY);
URL url = null;
try {
url = new URL(s);
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
return url;
}
};
mMap.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
}
您可以在这里找到更多的信息:的http://developer.android.com/reference/com/google/android/gms/maps/model/UrlTileProvider.html
You'll find more info here: http://developer.android.com/reference/com/google/android/gms/maps/model/UrlTileProvider.html
在这里: https://developers.google.com/maps/documentation/android/
这篇关于在谷歌地图Android版中的瓷砖图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!