PageSourceSearch

https://berlinstaiga.de/wp-content/plugins/osm/js/osm-v3-plugin-lib.js

js berlinstaiga.de collected 2026-10-02 23:35:22 UTC 6,439 bytes, 209 lines download raw bytes

1/*  (c) Copyright 2021  MiKa (http://wp-osm-plugin.Hyumika.com)
2
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; either version 2 of the License, or
6    (at your option) any later version.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16*/
17 
18function osm_addClusterPopupClickhandler(a_MapObj, a_MapStr) {
19
20  var container_div_id = a_MapStr + "_popup";
21  var content_div_id = a_MapStr + "_popup-content";
22  var closer_div_id = a_MapStr + "_popup-closer";
23
24  var container = document.getElementById(container_div_id);
25  var content = document.getElementById(content_div_id);
26  var closer = document.getElementById(closer_div_id);
27
28  var popup = new ol.Overlay(/** @type {olx.OverlayOptions} */ ({
29    element: container,
30    autoPan: true,
31    autoPanAnimation: {
32      duration: 250
33    }
34  }));
35        
36  closer.onclick = function() {
37    popup.setPosition(undefined);
38    closer.blur();
39    return false;
40  };
41            
42  a_MapObj.addOverlay(popup);
43
44  var ClickdisplayFeatureInfo = function(a_evt) {
45    var lonlat = ol.proj.transform(a_evt.coordinate, "EPSG:3857", "EPSG:4326");
46    var lon = lonlat[0];
47    var lat = lonlat[1];
48
49	 pixel = a_evt.pixel;
50		
51    var features = [];
52    var NumOfNamedFeatures = 0;
53    a_MapObj.forEachFeatureAtPixel(pixel, function(feature, layer) {
54      features.push(feature);
55    });
56    if (features.length > 0) {
57      
58      var name_str, desc_str, info = [];
59      var description_str = [];
60      var i, ii;
61      for (i = 0, ii = features.length; i < ii; ++i) {
62        var cluster_features = features[i].get('features');
63        if (cluster_features.length == 1){
64        if (cluster_features[i].get("name")){
65          NumOfNamedFeatures++;
66          name_str = cluster_features[i].get("name");
67          desc_str = cluster_features[i].get("desc");
68          description_str = features[i].get("description");
69          if (desc_str != undefined){
70            name_str = name_str + "<br>" + desc_str;
71          }
72          if (description_str != undefined){
73            name_str = name_str + "<br>" + description_str;
74          }
75          if (cluster_features[i].length > 0) {name_str = name_str + "<br>"}
76        }
77        else{
78
79        }
80        info.push(name_str);
81      }
82      }
83
84        content.innerHTML = info.join("") || "(unknown)";
85        if (NumOfNamedFeatures > 0){
86          popup.setPosition(a_evt.coordinate);
87        }
88         else {
89           popup.setPosition(undefined);
90        }
91      } 
92    };
93    a_MapObj.on("singleclick", function(evt) {ClickdisplayFeatureInfo(evt);}); 
94}
95
96
97
98function osm_addPopupClickhandler(a_MapObj, a_MapStr) {
99  var container_div_id = a_MapStr + "_popup";
100  var content_div_id = a_MapStr + "_popup-content";
101  var closer_div_id = a_MapStr + "_popup-closer";
102
103  var container = document.getElementById(container_div_id);
104  var content = document.getElementById(content_div_id);
105  var closer = document.getElementById(closer_div_id);
106
107  var popup = new ol.Overlay(/** @type {olx.OverlayOptions} */ ({
108    element: container,
109    autoPan: true,
110    autoPanAnimation: {
111      duration: 250
112    }
113  }));
114        
115  closer.onclick = function() {
116    popup.setPosition(undefined);
117    closer.blur();
118    return false;
119  };
120            
121  a_MapObj.addOverlay(popup);
122
123  var ClickdisplayFeatureInfo = function(a_evt) {
124    var lonlat = ol.proj.transform(a_evt.coordinate, "EPSG:3857", "EPSG:4326");
125    var lon = lonlat[0];
126    var lat = lonlat[1];
127
128	 pixel = a_evt.pixel;
129		
130    var features = [];
131    var NumOfNamedFeatures = 0;
132    a_MapObj.forEachFeatureAtPixel(pixel, function(feature, layer) {
133      features.push(feature);
134    });
135    if (features.length > 0) {
136      var name_str, desc_str, info = [];
137      var description_str = [];
138      var i, ii;
139      for (i = 0, ii = features.length; i < ii; ++i) {
140        if (features[i].get("name")){
141          NumOfNamedFeatures++;
142          name_str = features[i].get("name");
143          desc_str = features[i].get("desc");
144          description_str = features[i].get("description");
145          if (desc_str != undefined){
146            name_str = name_str + "<br>" + desc_str;
147          }
148          if (description_str != undefined){
149            name_str = name_str + "<br>" + description_str;
150          }
151          if (features.length > 0) {name_str = name_str + "<br>"}
152        }
153        else{
154          //name_str = "empty";
155        }
156        info.push(name_str);
157      }
158
159        content.innerHTML = info.join("") || "(unknown)";
160        if (NumOfNamedFeatures > 0){
161          popup.setPosition(a_evt.coordinate);
162        }
163         else {
164           popup.setPosition(undefined);
165        }
166      } 
167    };
168    a_MapObj.on("singleclick", function(evt) {ClickdisplayFeatureInfo(evt);}); 
169}
170
171
172
173
174function osm_addMarkerLayer(a_mapname, a_lon, a_lat, a_MarkerIcon, a_MarkerXAnchor, a_MarkerYAnchor, a_MarkerText) {
175  var iconFeature = new ol.Feature({
176    geometry: new ol.geom.Point(
177      ol.proj.transform([a_lon,a_lat], "EPSG:4326", "EPSG:3857")),
178    name: a_MarkerText
179  });
180        var iconStyle = new ol.style.Style({
181          image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
182            anchor: [(a_MarkerXAnchor * -1),(a_MarkerYAnchor * -1)],
183            anchorXUnits: "pixels",
184            anchorYUnits: "pixels",
185            opacity: 0.9,
186            src: a_MarkerIcon
187          }))
188        });
189        iconFeature.setStyle(iconStyle);
190
191        var vectorMarkerSource = new ol.source.Vector({
192          features: [iconFeature]
193        });
194
195        var vectorMarkerLayer = new ol.layer.Vector({
196          source: vectorMarkerSource,
197          zIndex: 92
198        });
199
200       a_mapname.addLayer(vectorMarkerLayer);
201}
202
203function osm_addMouseHover(a_mapname){
204  a_mapname.on('pointermove', function(evt) {
205    a_mapname.getTargetElement().style.cursor =
206      a_mapname.hasFeatureAtPixel(evt.pixel) ? 'pointer' : '';
207  });
208}
209

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.