-
Notifications
You must be signed in to change notification settings - Fork 75
WMS map layer
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.