May 2017
Beginner to intermediate
328 pages
7h 17m
English
Our first example renders a Window with an OpenLayers map inside. We add three layers to the map - all of them exposed via GeoServer. We need to create a map with the following code:
/** * Create map * @param mapContainerId */createMap: function(mapContainerId) { var proj = ol.proj.get('EPSG:4326'); this.map = new ol.Map({ layers: this.createLayers(), target: mapContainerId, controls: ol.control.defaults({ attributionOptions: { collapsible: false } }).extend([ new ol.control.ScaleLine(), new ol.control.MousePosition({ projection: proj, coordinateFormat: function(coords) { var output = ''; if (coords) { output = coords[0].toFixed(5) + ' : ' + coords[1].toFixed(5); } return output; } }) ]), view: new ol.View({ projection: ...Read now
Unlock full access