Ero sivun ”Widget:Ol3SeaBodyMapX” versioiden välillä
Järvi-meriwikistä
p (Tekstin korvaus – ”//cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL” muotoon ”https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js”) |
|||
(4 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
Rivi 2: | Rivi 2: | ||
<link rel="stylesheet" href="/scripts/ol3/ol.css" type="text/css"> | <link rel="stylesheet" href="/scripts/ol3/ol.css" type="text/css"> | ||
− | <script src="// | + | <script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js"></script> |
<script src="/scripts/ol3/ol.js"></script> | <script src="/scripts/ol3/ol.js"></script> | ||
Rivi 39: | Rivi 39: | ||
var page = '<!--{$page|escape:'urlpathinfo'}-->'; | var page = '<!--{$page|escape:'urlpathinfo'}-->'; | ||
+ | |||
+ | function gotCoords(request) { | ||
+ | |||
+ | for (var x in request.query.results) { | ||
+ | var resultItem = request.query.results[x].printouts; break; | ||
+ | } | ||
− | + | var lon = resultItem.KoordIta[0]; | |
+ | var lat = resultItem.KoordPohj[0]; | ||
+ | var zoom = parseInt(resultItem.Zoom[0]); | ||
+ | |||
+ | if (typeof resultItem.Base[0] != 'undefined') { | ||
+ | var base = resultItem.Base[0] | ||
+ | } else { | ||
+ | var base = 'osm'; | ||
+ | } | ||
+ | |||
+ | var vpdArr = resultItem.VPDTunnus; | ||
+ | |||
+ | //console.log(vpdArr); | ||
+ | |||
+ | var searchForVPDs = ''; | ||
+ | for (li in vpdArr) { | ||
+ | if (searchForVPDs.length > 0) { searchForVPDs += ' OR '; } | ||
+ | searchForVPDs += "VPDTunnus = '" + vpdArr[li] + "'"; | ||
+ | } | ||
+ | //console.log( searchForVPDs ); | ||
+ | var layersArr = []; | ||
layersArr.push({ | layersArr.push({ | ||
'type': 'seabody', | 'type': 'seabody', | ||
'name': 'Merialue', | 'name': 'Merialue', | ||
− | 'search': "", | + | 'search': searchForVPDs, |
+ | //'attribution': '<a href="//wwwp2.ymparisto.fi/kayttoehdot.html">Ympäristöhallinnon paikkatietoaineistot</a>', | ||
'visible': true, | 'visible': true, | ||
'opacitySlider': true, | 'opacitySlider': true, | ||
'showLabels': false, | 'showLabels': false, | ||
'selectable': false, | 'selectable': false, | ||
− | 'zoomToExtent | + | 'zoomToExtent': true |
− | |||
}); | }); | ||
+ | |||
+ | layersArr.push({ | ||
+ | 'type': 'sitesNobses', | ||
+ | 'name': 'Paikat ja havainnot', | ||
+ | 'siteSearch': "[[Alue::" + decodeURI(page) + "]]", | ||
+ | 'obsSearch': "[[Alue::" + decodeURI(page) + "]][[obsCode::ice||snow||temp||alg]]", | ||
+ | 'obsDays': 10, | ||
+ | 'opacitySlider': false, | ||
+ | 'selectable': true, | ||
+ | 'zoomToExtent': false | ||
+ | }); | ||
+ | |||
+ | //layersArr.push({ 'type': 'geoloc', 'name': 'Sijaintisi', 'show': true, 'center': false, 'zoom': 12, 'track': false }); | ||
// do the base map with these settings | // do the base map with these settings | ||
var map = ol3_jwMakeMap({ | var map = ol3_jwMakeMap({ | ||
'container': '<!--{$id|default:CommonObsMap|escape:'html'}-->_container', | 'container': '<!--{$id|default:CommonObsMap|escape:'html'}-->_container', | ||
− | 'base': | + | 'base': base, |
− | 'lon': | + | 'lon': lon, |
− | 'lat': | + | 'lat': lat, |
− | 'zoom': | + | 'zoom': zoom, |
'layers': layersArr, | 'layers': layersArr, | ||
'memo': memo | 'memo': memo | ||
}); | }); | ||
− | } | + | } |
+ | |||
+ | var searchStr = 'action=ask&query=[[' + page + ']]'; | ||
+ | searchStr += encodeURI('|?KoordPohj|?KoordIta|?Zoom|?Base|?VPDTunnus'); | ||
+ | searchStr += '&format=json'; | ||
+ | |||
+ | jQuery.ajax({ | ||
+ | type: 'GET', | ||
+ | url: queryApi, | ||
+ | data: searchStr, | ||
+ | success: gotCoords, | ||
+ | dataType: 'jsonp', | ||
+ | cache: true | ||
+ | }); | ||
+ | |||
+ | } | ||
+ | |||
</script> | </script> | ||
</includeonly> | </includeonly> |