Reputation: 51
I am trying to add a WMS Layer to Here Maps, but I do not find any starting point for doing that within their documentation...Also I did not find anything related to that here.
Has anyone expereience with WMS Layers in Here Map? So far I managed to work with WMS Layers in MapKit and OpenLayers. But the client is also interested in a HereMaps based approach.
My assumption is, that i need to setup the URL to my geoserver from here:
func mapTileLayer(_ mapTileLayer: NMAMapTileLayer, urlForTileAtX x: UInt, y: UInt, zoomLevel: UInt) -> String
But how can I transform x y to a bounding box?
Any help greatly appreciated!
Upvotes: 2
Views: 892
Reputation: 43671
I have no idea about Swift, MapKit and Here Maps, so I'm best qualified to give an answer. :)
And here it is.
Since you're using a GeoServer, configure it to publish your layer as a WMTS/tile layer and use the tile set configuration which matches whatever you use in Here Maps (most probably Spherical Mercator/EPSG:900913). That should be more or less standard setting (last time I looked).
In this case it is trivial to create an URL from x
, y
and z
, Will be just something like http://some-base.url/mygeoserver/.../${z}/${x}/${y}.png
- something along the lines.
You can also turn on tile caching and pre-render tiles on upper zoom levels for better performance.
If you for some reason can't or don't want to configure the tile layer, I'd like to know the reason. :)
In this case you still can calculate the bounding box for your tiles coordinates. See the following links:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Tile_bounding_box
To quote the OSM Wiki:
func tileToLatLon(tileX : Int, tileY : Int, mapZoom: Int) -> (lat_deg : Double, lon_deg : Double) {
let n : Double = pow(2.0, Double(mapZoom))
let lon = (Double(tileX) / n) * 360.0 - 180.0
let lat = atan( sinh (.pi - (Double(tileY) / n) * 2 * Double.pi)) * (180.0 / .pi)
return (lat, lon)
}
That results in EPSG:4326. If you need a different coordinate system, things get much more complicated.
Also you target coordinate system must "match" the original coordinate system in a sense that the resulting bounding box is not "rotated".
Upvotes: 1