diff options
author | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
commit | ea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch) | |
tree | af67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/examples/polar-projections.js | |
parent | 59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff) | |
download | postrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip |
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/examples/polar-projections.js')
-rw-r--r-- | misc/openlayers/examples/polar-projections.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/misc/openlayers/examples/polar-projections.js b/misc/openlayers/examples/polar-projections.js new file mode 100644 index 0000000..ac717fb --- /dev/null +++ b/misc/openlayers/examples/polar-projections.js @@ -0,0 +1,84 @@ +var map, layer, overlay; + +var projectionOptions = { + 'EPSG:3574': { + projection: new OpenLayers.Projection('EPSG:3574'), + units: 'm', + maxExtent: new OpenLayers.Bounds(-5505054, -5505054, 5505054, 5505054), + maxResolution: 5505054 / 128, + numZoomLevels: 18 + }, + 'EPSG:3576': { + projection: new OpenLayers.Projection('EPSG:3576'), + units: 'm', + maxExtent: new OpenLayers.Bounds(-5505054, -5505054, 5505054, 5505054), + maxResolution: 5505054 / 128, + numZoomLevels: 18 + }, + 'EPSG:3571': { + projection: new OpenLayers.Projection('EPSG:3571'), + units: 'm', + maxExtent: new OpenLayers.Bounds(-5505054, -5505054, 5505054, 5505054), + maxResolution: 5505054 / 128, + numZoomLevels: 18 + }, + 'EPSG:3573': { + projection: new OpenLayers.Projection('EPSG:3573'), + units: 'm', + maxExtent: new OpenLayers.Bounds(-5505054, -5505054, 5505054, 5505054), + maxResolution: 5505054 / 128, + numZoomLevels: 18 + } +}; + +function setProjection() { + projCode = this.innerHTML; + var oldExtent = map.getExtent(); + var oldCenter = map.getCenter(); + var oldProjection = map.getProjectionObject(); + + // map projection is controlled by the base layer + map.baseLayer.addOptions(projectionOptions[projCode]); + + // with the base layer updated, the map has the new projection now + var newProjection = map.getProjectionObject(); + + // transform the center of the old projection, not the extent + map.setCenter( + oldCenter.transform(oldProjection, newProjection, + map.getZoomForExtent(oldExtent.transform(oldProjection, newProjection)) + )); + + for (var i=map.layers.length-1; i>=0; --i) { + // update grid settings + map.layers[i].addOptions(projectionOptions[projCode]); + // redraw layer - just in case center and zoom are the same in old and + // new projection + map.layers[i].redraw(); + } +} + +function init() { + map = new OpenLayers.Map('map'); + layer = new OpenLayers.Layer.WMS( + 'world', + 'http://v2.suite.opengeo.org/geoserver/wms', + {layers: 'world', version: '1.1.1'}, + projectionOptions['EPSG:3574'] + ); + overlay = new OpenLayers.Layer.WMS( + 'world', + 'http://v2.suite.opengeo.org/geoserver/wms', + {transparent: 'true', layers: 'world:borders', styles: 'line'}, + projectionOptions['EPSG:3574'] + ); + overlay.isBaseLayer = false; + map.addLayers([layer, overlay]); + map.zoomToMaxExtent(); + + // add behaviour to dom elements + document.getElementById('epsg3574').onclick = setProjection; + document.getElementById('epsg3576').onclick = setProjection; + document.getElementById('epsg3571').onclick = setProjection; + document.getElementById('epsg3573').onclick = setProjection; +} |