Widget:OpenLayersM
<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 target = document.getElementById();
var ajaxRequests = 0;
var map; var epsg4326 = new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection var mapProjStr = "3857"; var projectTo = new OpenLayers.Projection("EPSG:" + mapProjStr); //The map projection
var searchStr = "action=ask&q=[[]]"; searchStr += "&po=|KoordPohjMin|KoordItaMin|KoordPohjMax|KoordItaMax|Järvinumero&format=json"; ajaxRequests++; jQuery.ajax({
type: 'GET', url: '//www.jarviwiki.fi/w/api.php', data: searchStr, success: success, dataType: 'jsonp', cache: true
});
var searchStr = "action=ask&q="; searchStr += "&po=Koordinaatit&format=json"; ajaxRequests++; jQuery.ajax({
type: 'GET', url: '//www.jarviwiki.fi/w/api.php', data: searchStr, success: successP, dataType: 'jsonp', cache: true
});
function successP(request) {
//alert(request.ask.results.items[0].title); ajaxRequests--; if (ajaxRequests == 0) { spinner.stop(); }
}
//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" }));
function success(request) {
var props = request.ask.results.items[0].properties; var jnum = new Array(); if (jQuery.isArray(props.järvinumero)) {
jnum = props.järvinumero;
} else {
jnum = [props.järvinumero];
} jnum = ['91.41'];
vpdQueryStr = ""; vpdQueryStr2 = ""; jnumQueryStr = ""; jnumQueryStr2 = ""; vesalQueryStr2 = "Jako3Tunnus LIKE '91.41%'";
for (j=0; j<jnum.length; j++) {
vpdQueryStr += '+OR+VPDTunnus+LIKE+%27' + jnum[j] + '%25%27'; vpdQueryStr2 += " OR VPDTunnus LIKE '" + jnum[j] + "%'"; jnumQueryStr += '+OR+JarviTunnus+%3D+%27' + jnum[j] + '%27'; jnumQueryStr2 += " OR JarviTunnus = '" + jnum[j] + "'";
} vpdQueryStr = vpdQueryStr.substring(4); vpdQueryStr2 = vpdQueryStr2.substring(4); jnumQueryStr = jnumQueryStr.substring(4); jnumQueryStr2 = jnumQueryStr2.substring(4);
alert('//paikkatieto.ymparisto.fi/arcgis/rest/services/INSPIRE/' +
'SYKE_AlueidenHallintaJaRajoitukset1/MapServer/3/query' + '?&where=' + vpdQueryStr + '&returnCountOnly=true&f=pjson');
///////////////////// Järven rajaus jQuery.ajax({
type: 'GET', url: '//paikkatieto.ymparisto.fi/arcgis/rest/services/INSPIRE/' + 'SYKE_AlueidenHallintaJaRajoitukset1/MapServer/2/query', data: '&where=' + vpdQueryStr + '&returnCountOnly=true&f=pjson', success: function(request) { if (request.count != 0) { var lr = new OpenLayers.Layer.ArcGIS93Rest( 'Järven rajat', '//paikkatieto.ymparisto.fi/arcgis/rest/services/INSPIRE/' + 'SYKE_AlueidenHallintaJaRajoitukset1/MapServer/export', { layers: "show:2", version: '1.3.0', crs: mapProjStr, TRANSPARENT: true }, { isBaseLayer: false, opacity: 0.8 } ); lr.setLayerFilter(2, vpdQueryStr2); map.addLayer(lr); } }, dataType: 'jsonp'
}); /////////////////////
var lonMin = parseFloat(props.koorditamin.replace(',', '.')); var lonMax = parseFloat(props.koorditamax.replace(',', '.')); var latMin = parseFloat(props.koordpohjmin.replace(',', '.')); var latMax = parseFloat(props.koordpohjmax.replace(',', '.'));
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);
ajaxRequests--;
}
</script>