This article is a basic integration guide for using WMS tile servers with osmdroid.
It's not perfect and will not work with many use cases.
GetCapabilities
documentWMSEndpoint
contains the bare minimum needed for layer selection and some minor presentation detailsWMSEndpoint
's layers can then be presented to the user for selectionWMSEndpoint
and the WMSLayer
Server's we have tested against
The following coordinate/spatial reference systems (CRS/SRS) are supported
General WMS server requirements
Styling per layer is supported, the first style is auto selected.
Multiple tile layers active at the same time is not currently supported (this would be useful for getting the best tile available as you zoom in and out).
WMS library was added in 6.0 of osmdroid. It may not yet be published, see the osmdroid readme for details.
dependencies {
compile 'org.osmdroid:osmdroid-wms:<VERSION>'
}
Note, error handling is omitted for brievity
HttpURLConnection c = null;
InputStream is = null;
WMSEndpoint wmsEndpoint;
c = (HttpURLConnection) new URL(youEditTextValue).openConnection();
is = c.getInputStream();
wmsEndpoint = WMSParser.parse(is);
is.close();
c.disconnect();
Here is a great spot to prompt the user for some kind of layer selection.
Here we are selecting the first layer and telling osmdroid to use it.
WMSTileSource source = WMSTileSource.createFrom(wmsEndpoint, wmsEndpoint.getLayers().get(0) );
if (layer.getBbox() != null) {
//center map on this location
mMapView.zoomToBoundingBox(layer.getBbox(),true);
}
mMapView.setTileSource(source);