|
|
| Rivi 1: |
Rivi 1: |
| <includeonly> | | <includeonly> |
| | | |
|
| |
| <link rel="stylesheet" href="/scripts/ol-10/ol.css" type="text/css"> | | <link rel="stylesheet" href="/scripts/ol-10/ol.css" type="text/css"> |
| <script src="/scripts/ol-10/ol.js"></script>
| | <script src="/scripts/ol-10/ol.js"></script> |
| | | |
| <link rel="stylesheet" href="/scripts/ol-ext-10/dist/ol-ext.min.css" type="text/css"> | | <link rel="stylesheet" href="/scripts/ol-ext-10/dist/ol-ext.min.css" type="text/css"> |
| Rivi 17: |
Rivi 16: |
| | | |
| <script type="text/javascript"> | | <script type="text/javascript"> |
| | |
| //global memory for widget instance | | //global memory for widget instance |
| var <!--{$id|default:CommonObsMap|escape:'html'}-->_memo = { 'SitesO': {}, 'TypesO': {}, 'obsTypeToShow': '' }; | | var <!--{$id|default:CommonObsMap|escape:'html'}-->_memo = { 'SitesO': {}, 'TypesO': {}, 'obsTypeToShow': '' }; |
|
| |
|
| function <!--{$id|default:CommonObsMap|escape:'html'}-->_jQueryTest() { | | function <!--{$id|default:CommonObsMap|escape:'html'}-->_jQueryTest() { |
| if ( typeof window.jQuery == 'undefined' ) {
| | if ( typeof window.jQuery == 'undefined' ) { |
| setTimeout( function(){ <!--{$id|default:CommonObsMap|escape:'html'}-->_jQueryTest() }, 300);
| | setTimeout( function(){ <!--{$id|default:CommonObsMap|escape:'html'}-->_jQueryTest() }, 300); |
| } else {
| | } else { |
| <!--{$id|default:CommonObsMap|escape:'html'}-->_func();
| | <!--{$id|default:CommonObsMap|escape:'html'}-->_func(); |
| }
| | } |
| } | | } |
| setTimeout( function(){ <!--{$id|default:CommonObsMap|escape:'html'}-->_jQueryTest() }, 300); | | setTimeout( function(){ <!--{$id|default:CommonObsMap|escape:'html'}-->_jQueryTest() }, 300); |
|
| |
|
| function <!--{$id|default:CommonObsMap|escape:'html'}-->_func() { | | function <!--{$id|default:CommonObsMap|escape:'html'}-->_func() { |
| Rivi 37: |
Rivi 37: |
| var lon = parseFloat('<!--{$lon|default:25|escape:'html'}-->'); | | var lon = parseFloat('<!--{$lon|default:25|escape:'html'}-->'); |
| var lat = parseFloat('<!--{$lat|default:65|escape:'html'}-->'); | | var lat = parseFloat('<!--{$lat|default:65|escape:'html'}-->'); |
| | var zoom = parseInt('<!--{$zoom|default:4|escape:'html'}-->'); |
| | var page = '<!--{$page|escape:'html'}-->'; |
| | var muni = page.replace(' (kunta)', ''); |
| | var base = '<!--{$base|default:mmlTausta|escape:'html'}-->'; |
| | | |
| var zoom = jQuery('.jwZoom').first().val();
| | function gotSeaVPDs(request) { |
| if (!zoom) { zoom = <!--{$zoom|default:5|escape:'html'}-->; }
| | |
|
| |
| var base = '<!--{$base|default:osm|escape:'html'}-->';
| |
| | |
| //var lon = jQuery('.jwLon').first().val().replace(',', ',');
| |
| //var lat = jQuery('.jwLat').first().val().replace(',', ',');
| |
| var parent = jQuery('.jwParent').first().val();
| |
|
| |
| parent='Välijärvi (74.021.1.051)';
| |
| var newSite = true;
| |
|
| |
| function gotCoords(request) { | |
|
| |
| //console.log(request);
| |
|
| |
| var layersArr = []; | | var layersArr = []; |
|
| | /* |
| for (var r in request.query.results) { | | layersArr.push( { |
|
| | 'id': 'muni', |
| var body = request.query.results[r]; | | 'type': 'anyrest', |
|
| | 'name': 'Kunta', |
| if (typeof body.printouts['Järvinumero'][0] != 'undefined') { | | 'restUrl': '//paikkatieto.ymparisto.fi/arcgis/rest/services/sykemaps/GISAineistot2/MapServer/0/query', |
| layersArr.push( {
| | 'search': "KuntaNimi = '" + muni + "'", |
| 'type': 'lake',
| | 'selectable': false, |
| 'name': body.fulltext,
| | 'zoomToExtent': true, |
| 'search': "JarviTunnus = '" + body.printouts['Järvinumero'][0] + "'",
| | 'bbox': false, |
| 'opacitySlider': true,
| | 'fillColor': 'rgba( 0, 0, 0, 0 )', |
| 'showLabels': false,
| | 'strokeColor': 'rgba( 200, 100, 100, 0.5 )', |
| 'selectable': false,
| | 'strokeWidth': 5 |
| 'zoomToExtent': newSite
| | //'attribution': '<a href="//wwwp2.ymparisto.fi/kayttoehdot.html">Ympäristöhallinnon paikkatietoaineistot</a>', |
| } );
| | }); |
| layersArr.push( {
| | */ |
| 'type': 'sitesNobses',
| | layersArr.push( { |
| 'name': 'Paikat ja havainnot',
| | 'id': 'muni', |
| 'siteSearch': '[[Alue::' + parent + ']]',
| | 'type': 'anygeoserver', |
| 'obsSearch': '',
| | 'name': 'Kunta', |
| //'obsDays': 10,
| | 'restUrl': 'https://inspire-wfs.maanmittauslaitos.fi/inspire-wfs/au/ows?version=2.0.0', |
| //'attribution': 'Havainnot: Järvi-meriwiki',
| | //'search': "KuntaNimi = '" + muni + "'", |
| 'opacitySlider': false,
| | 'cql_filter': 'nationalcode%20=%20611', |
| 'selectable': true,
| | 'selectable': false, |
| 'zoomToExtent': false
| | 'zoomToExtent': true, |
| });
| | 'bbox': false, |
|
| | 'fillColor': 'rgba( 0, 0, 0, 0 )', |
| } else if (typeof body.printouts['Vesistöaluenumero'][0] != 'undefined') {
| | 'strokeColor': 'rgba( 200, 100, 100, 0.5 )', |
| layersArr.push( {
| | 'strokeWidth': 5 |
| 'type': 'drainage',
| | //'attribution': '<a href="//wwwp2.ymparisto.fi/kayttoehdot.html">Ympäristöhallinnon paikkatietoaineistot</a>', |
| 'name': body.fulltext,
| | }); |
| 'search': "Jako3Tunnus = '" + body.printouts['Vesistöaluenumero'][0] + "'",
| | |
| 'opacitySlider': true,
| |
| 'showLabels': false,
| |
| 'selectable': false,
| |
| 'zoomToExtent': newSite
| |
| } );
| |
|
| |
| } else if (typeof body.printouts['VPDTunnus'][0] != 'undefined') {
| |
| layersArr.push( {
| |
| 'type': 'vpd',
| |
| 'name': body.fulltext,
| |
| 'search': "VPDTunnus = '" + body.printouts['VPDTunnus'][0] + "'",
| |
| 'opacitySlider': true,
| |
| 'showLabels': false,
| |
| 'selectable': false,
| |
| 'zoomToExtent': newSite
| |
| } );
| |
| } | |
|
| |
| break; | |
| }
| |
|
| |
| layersArr.push( { 'type': 'geolocX', 'name': 'Sijaintisi', 'show': true, 'center': true, 'zoom': 18, 'track': false, 'button': true } );
| |
|
| |
| // do the base map with these settings | | // do the base map with these settings |
| var map = jwMakeMap({ | | var map = jwMakeMap({ |
| Rivi 122: |
Rivi 89: |
| }); | | }); |
|
| |
|
| target = new ol.control.Target();
| | } |
| map.addControl(target);
| |
|
| |
| // set mousewheelzoom not to change center
| |
| var mouseZoom = new ol.interaction.MouseWheelZoom( { useAnchor: false } );
| |
| map.addInteraction(mouseZoom);
| |
|
| |
| var drawSource = new ol.source.Vector();
| |
| var drawLayer = new ol.layer.Vector({
| |
| name: 'Alue',
| |
| source: drawSource
| |
| });
| |
| map.addLayer(drawLayer);
| |
|
| |
| // Edit control bar
| |
| var editbar = new ol.control.Bar({
| |
| toggleOne: true,
| |
| //group: true
| |
| });
| |
| map.addControl(editbar);
| |
|
| |
| var selectCtrl = new ol.control.Toggle({
| |
| html: '<i class="fa fa-hand-pointer-o"></i>',
| |
| title: "Select",
| |
| interaction: new ol.interaction.Select (),
| |
| //bar: sbar,
| |
| autoActivate:true,
| |
| active:true
| |
| });
| |
| | |
| // Add editing tools
| |
| var pedit = new ol.control.Toggle({
| |
| html: '<img src="//www.jarviwiki.fi/dynpm/ol/jw_ol_drawPoint_24px.png">', //'<i class="fa fa-map-marker" ></i>',
| |
| title: 'Point',
| |
| interaction: new ol.interaction.Draw({
| |
| type: 'Point',
| |
| source: drawSource
| |
| })
| |
| });
| |
| | |
| var ledit = new ol.control.Toggle({
| |
| html: '<i class="fa fa-share-alt" ></i>',
| |
| title: 'LineString',
| |
| interaction: new ol.interaction.Draw({
| |
| type: 'LineString',
| |
| source: drawSource,
| |
| // Count inserted points
| |
| geometryFunction: function(coordinates, geometry) {
| |
| if (geometry) geometry.setCoordinates(coordinates);
| |
| else geometry = new ol.geom.LineString(coordinates);
| |
| this.nbpts = geometry.getCoordinates().length;
| |
| | |
| console.log('dddd');
| |
| return geometry;
| |
| }
| |
| }),
| |
| });
| |
| | |
| var fedit = new ol.control.Toggle({
| |
| html: '<img src="//www.jarviwiki.fi/dynpm/ol/jw_ol_drawPolygon_24px.png">', //'<i class="fa fa-bookmark-o fa-rotate-270" ></i>',
| |
| title: 'Polygon',
| |
| interaction: new ol.interaction.Draw({
| |
| type: 'Polygon',
| |
| source: drawSource,
| |
| // Count inserted points
| |
| geometryFunction: function(coordinates, geometry) {
| |
| this.nbpts = coordinates[0].length;
| |
| if (geometry) geometry.setCoordinates([coordinates[0].concat([coordinates[0][0]])]);
| |
| else geometry = new ol.geom.Polygon(coordinates);
| |
| return geometry;
| |
| }
| |
| }),
| |
| });
| |
|
| |
| var drawSelect = new ol.interaction.Select();
| |
| map.addInteraction(drawSelect);
| |
|
| |
| var medit = new ol.control.Toggle({
| |
| html: '<img src="//www.jarviwiki.fi/dynpm/ol/jw_ol_drawEdit_24px.png">', //'<i class="fa fa-bookmark-o fa-rotate-270" ></i>',
| |
| title: 'Edit',
| |
| interaction: new ol.interaction.Modify({
| |
| features: drawSelect.getFeatures(),
| |
| //type: 'Polygon',
| |
| source: drawSource,
| |
| // Count inserted points
| |
| //geometryFunction: function(coordinates, geometry) {
| |
| // this.nbpts = coordinates[0].length;
| |
| // if (geometry) geometry.setCoordinates([coordinates[0].concat([coordinates[0][0]])]);
| |
| // else geometry = new ol.geom.Polygon(coordinates);
| |
| // return geometry;
| |
| //}
| |
| }),
| |
| });
| |
| | |
| editbar.addControl ( selectCtrl );
| |
| editbar.addControl ( pedit );
| |
| editbar.addControl ( ledit );
| |
| editbar.addControl ( fedit );
| |
| editbar.addControl ( medit );
| |
|
| |
| jQuery('#jwChosenObsTypeContainer').html('Siirrä ja zoomaa karttaa kunnes risti osoittaa tarkoittamaasi paikkaan');
| |
|
| |
|
| map.on('moveend', function() {
| | var searchStr = 'action=ask&query=[[Luokka:Merialue]][[Kunta::' + page + ']]'; |
|
| | searchStr += encodeURI('|?VPDTunnus'); |
| var centerLonLat = (ol.proj.transform(map.getView().getCenter(), 'EPSG:3857', 'EPSG:4326'));
| | searchStr += '&format=json'; |
| jQuery('.jwLon').val(centerLonLat[0]);
| | |
| jQuery('.jwLat').val(centerLonLat[1]);
| | jQuery.ajax({ |
| jQuery('.jwZoom').val(map.getView().getZoom());
| | type: 'GET', |
| | | url: queryApi, |
| });
| | data: searchStr, |
|
| | success: gotSeaVPDs, |
| map.getLayers().item(0).on('change', function(e) {
| | dataType: 'jsonp', |
|
| | cache: true |
| var baseLayers = e.target.getLayers(); // map.getLayerGroup().getLayers().item(0).getLayers();
| | }); |
| baseLayers.forEach(function (layer) {
| |
| if (layer.get('visible') == true) {
| |
| var title = (layer.get('title'));
| |
| if (title == 'MML Taustakartta') {
| |
| jQuery('.jwBase').val('MMLTausta');
| |
| } else if (title == 'MML Ortokuva') {
| |
| jQuery('.jwBase').val('MMLOrto');
| |
| } else {
| |
| jQuery('.jwBase').val('osm');
| |
| }
| |
| //console.log(title);
| |
| }
| |
| });
| |
| });
| |
|
| |
| }
| |
|
| |
| if (!!parent) {
| |
| var searchStr = 'action=ask&query=[[' + parent + ']]';
| |
| searchStr += encodeURI('|?KoordPohj|?KoordIta|?KoordPohjMin|?KoordItaMin|?KoordPohjMax|?KoordItaMax|?Zoom|?Järvinumero|?VPDTunnus|?Vesistö|?Vesistöaluenumero|?Luokka');
| |
| searchStr += '&format=json';
| |
| | |
| jQuery.ajax({
| |
| type: 'POST',
| |
| url: queryApi,
| |
| data: searchStr,
| |
| success: gotCoords,
| |
| dataType: 'jsonp',
| |
| cache: true
| |
| });
| |
| } else {
| |
|
| |
|
| |
| }
| |
|
| |
|
| |
|
| |
|
|
| |
|
| } | | } |
|
| |
|
| |
|
| </script> | | </script> |
|
| |
|
| </includeonly> | | </includeonly> |