I am doing a project on Google map. My requirement is to save the Google map when online and to use in offline mode. In Ios, they used GMSTileURLConstructor. In the same, Is there any probabilities to save map. If yes, can you provide me any idea or link.
-(void)ViewOfflineMap
{
GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) {
NSString *strMap=[NSString stringWithFormat:@"http://mt0.google.com/vt/x=%ld&y=%ld&z=%ld",(long)x,(long)y,(long)zoom];
return [NSURL URLWithString:strMap];
};
GMSURLTileLayer *layer=[GMSURLTileLayer tileLayerWithURLConstructor:urls];
layer.zIndex=100;
layer.map=mapView_;
}
Thanks in advance.
I have one solution. We can save map as tiles using UrlTileProvider. It saves the map tiles, based on the zooming level and x and y axis covered area in your screen.
TileProvider tileProvider = new UrlTileProvider(256, 256) {
@Override
public URL getTileUrl(int x, int y, int zoom) {
String s = String.format(
"http://my.image.server/images/%d%d%d.png", zoom, x, y);
if (!checkTileExists(x, y, zoom)) {
return null;
}
try {
return new URL(s);
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
private boolean checkTileExists(int x, int y, int zoom) {
int minZoom = 12;
int maxZoom = 16;
if ((zoom < minZoom || zoom > maxZoom)) {
return false;
}
return true;
}
};
tileOverlay = map.addTileOverlay(new TileOverlayOptions()
.tileProvider(tileProvider));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With