Skip to content
Nutiteq edited this page May 7, 2014 · 6 revisions

WMSRasterDataSource calculates WMS request parameters for each tile, and initiates tile download task.

Yuo can use different projection for map and for the WMS, then the WMS requests are done in another projection.

Important note: Currently base map needs to be in EPSG3857, and you can use custom projection for WMS overlay. You cannot use custom projection WMS as baseLayer yet.

There is no WMS GetCapabilities request implementation, so service URL is directly for map images, and you need to define specific layer and styles.

  String url = "http://kaart.maakaart.ee/geoserver/wms?transparent=true&";
  String layers = "topp:states";

  // note that data projection is different: WGS84 (EPSG:4326)
  WMSRasterDataSource wmsDataSource = new WMSRasterDataSource(
       new EPSG4326(), 0, 19, url, "", layers, "image/png");
  RasterLayer wmsLayer = new RasterLayer(wmsDataSource, 1012);
  wmsLayer.setFetchPriority(-5);
  mapView.getLayers().addLayer(wmsLayer);

Some WMS servers may need user passwords. For Http Basic Authentication try following:

        Map<String, String> authHeader = new HashMap<String,String>();
        authHeader.put("Authorization", "basic " +
              Base64.encode("MY_USER_NAME:MY_PASSWORD".getBytes(), Base64.DEFAULT));
        wmsDataSource.setHttpHeaders(authHeader);

There is also support for GetFeatureInfo WMS request, so if server supports it then you can request extra info for clicked points. See WMSFeatureClickListener.java in AdvancedMap3D project.

WMS GetFeatureInfo with Geoserver and HTML label

Clone this wiki locally