Map API

Nutiteq Maps Lib SDK enables developing advanced mobile mapping applications.
Platforms: Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »
Untitled Document

Products

» View demos
» Downloads

Latest news

Last at Tue, 6 Dec 2011 18:37:53
Topic: New BlackBerry sample app
See more news »

How to create raster map overlays (hybrid maps)

No replies
jaak
User offline. Last seen 1 day 9 hours ago. Offline
Joined: 06/19/2008

How to add map image overlays, e.g. satellite image as a base and own vector data on top of that, like Google hybrid map?

Preconditions:
a) overlay map must use same tile system (projection, tile size etc) as base layer. So they must cover each other exactly. Numbering could be different (e.g. zoom levels or xyz vs q-tree, but otherwise tile must be the same
b) overlay maps should be semi-transparent.

Steps:
1. Create new base map

GeoMap baseMap = OpenStreetMap.MAPNIK;

2. Create overlay class which has to implement com.nutiteq.maps.MapTileOverlay. Here is my OsmOverlay.java which implements OSM tile format:

import com.nutiteq.components.MapTile;
import com.nutiteq.maps.MapTileOverlay;

public class OsmOverlay implements MapTileOverlay {
 private final String baseUrl;	
 public MyQuadKeyOverlay(final String baseUrl) {
   this.baseUrl = baseUrl;
 }
	
 public String getOverlayTileUrl(final MapTile tile) {
    
  final int tmpX = tile.getX() >> 8;
  final int tmpY = tile.getY() >> 8;
	
  final int zoom = tile.getZoom();

  final StringBuffer url = new StringBuffer(baseUrl);
   url.append(zoom);
   url.append("/");
   url.append(x);
   url.append("/");
   url.append(y);
   url.append(".png");

   return url.toString();
 }
}

3. Add overlay to map. I use here OSM semitransparent tiles created by somebody with unknown usage conditions:

baseMap.addTileOverlay(new OsmOverlay("http://t3-overlay.hypercube.telascience.org/tiles/1.0.0/osm-merc-google-hybrid"));

4. Add map (now with overlay) to MapComponent

map.setMap(baseMap);

This will actually create OSM map in top of OSM map, but as long as OpenAerialMap is dead, then I've got no free aerial image source to be used.

/JaakL