Widget:OLTest
<script type="text/javascript" src="//www.jarviwiki.fi/api/common/OpenLayers-2.12/OpenLayers.js"></script> <script type="text/javascript" src="//www.jarviwiki.fi/api/common/OpenLayers-2.12/lib/OpenLayers/Lang/fi.js"></script> <script type="text/javascript" src="//www.jarviwiki.fi/api/common/OpenLayers-2.12/lib/OpenLayers/Lang/sv-SE.js"></script> <script type="text/javascript"> var map; var epsg4326 = new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection //var mapProjStr = "102113"; //var mapProjStr = "900913"; var mapProjStr = "3857"; var projectTo = new OpenLayers.Projection("EPSG:" + mapProjStr); //The map projection
//map object var options = {
projection: "EPSG:" + mapProjStr,
units: "m", controls: [ new OpenLayers.Control.Navigation({zoomWheelEnabled : false}), new OpenLayers.Control.Zoom(), new OpenLayers.Control.LayerSwitcher({'ascending':false}), new OpenLayers.Control.Attribution() ] };
map = new OpenLayers.Map( , options );
//OpenStreetMap osm = new OpenLayers.Layer.OSM("OpenStreetMap", null, {
sphericalMercator: true, projection: projectTo, transitionEffect: "resize", attribution: "© <a href='//www.openstreetmap.org/copyright'>OpenStreetMapin tekijät</a>"
});
map.addLayer(osm);
//Peruskartta map.addLayer(new OpenLayers.Layer.WMS("Peruskartta", "//tiles.kartat.kapsi.fi/peruskartta?", {layers: 'peruskartta'}, {projection: 'EPSG:900913', attribution: "asdf" }));
//Ortoilmakuvat map.addLayer(new OpenLayers.Layer.WMS("Ortoilmakuvat", "//tiles.kartat.kapsi.fi/ortokuva?", {layers: 'ortokuva'}, {projection: 'EPSG:900913', attribution: "asdforto" }));
//Ortoilmakuvat map.addLayer(new OpenLayers.Layer.WMS("Taustakartta", "//tiles.kartat.kapsi.fi/taustakartta?", {layers: 'taustakartta'}, {projection: 'EPSG:900913', attribution: "asdforto" }));
///////////////////// Järven rajaus
var lr = new OpenLayers.Layer.ArcGIS93Rest(
'Joet', '//paikkatieto.ymparisto.fi/arcgis/rest/services/INSPIRE/' + 'SYKE_Hydrografia/MapServer/export', { layers: "show:7", version: '1.3.0', crs: mapProjStr, TRANSPARENT: true}, { isBaseLayer: false, opacity: 0.8 } ); //lr.setLayerFilter(8, "VPDTunnus LIKE '" + props.järvinumero + "%'"); map.addLayer(lr);
/////////////////////
var lonMin = 20; var lonMax = 30; var latMin = 60; var latMax = 70;
bounds = new OpenLayers.Bounds(); bounds.extend(new OpenLayers.LonLat(lonMin,latMin).transform(epsg4326, projectTo)); bounds.extend(new OpenLayers.LonLat(lonMax,latMax).transform(epsg4326, projectTo)); map.zoomToExtent(bounds);
</script>