PageSourceSearch

https://eric.van-der-vlist.com/wp-content/plugins/osm/js/osm-plugin-lib.js?ver=6.4.3

js van-der-vlist.com collected 2026-10-03 21:42:00 UTC 15,737 bytes, 481 lines download raw bytes

1/*
2  OSM OpenLayers for OSM wordpress plugin
3  plugin: http://wp-osm-plugin.hyumika.com
4  blog:   http://www.hyumika.com
5*/
6
7// Display Disc / Circles
8function osm_getFeatureDiscCenter(a_tileLayer, a_discLayer, a_lon, a_lat, a_radius, a_centeropac, a_centercol, a_strw, a_strcol, a_stropac, a_fillcol, a_fillopac) 
9{
10    var lonLat = new OpenLayers.LonLat(a_lon, a_lat).transform(a_tileLayer.displayProjection, a_tileLayer.projection);
11
12    var discStyle    = { strokeColor: a_strcol,
13                         strokeOpacity: a_stropac,
14                         strokeWidth: a_strw,
15                         fillColor: a_fillcol,
16                         fillOpacity: a_fillopac
17                       };
18    var centerStyle  = { strokeColor: a_centercol,
19                         strokeOpacity: a_centeropac,
20                         strokeWidth: a_strw,
21                         fillColor: a_centercol,
22                         fillOpacity: a_centeropac
23                       };
24
25    var radius = a_radius / Math.cos(a_lat*(Math.PI/180));
26
27    var disc = OpenLayers.Geometry.Polygon.createRegularPolygon(
28                                             new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat),
29                                             radius,
30                                             200); // nombre de faces
31                 
32    var center = OpenLayers.Geometry.Polygon.createRegularPolygon(
33                                             new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat),
34                                             1,   // taille dans lunite de la carte
35                                             5);  // nombre de faces
36                 
37
38    var featureDisc   = new OpenLayers.Feature.Vector(disc,null,discStyle);
39    var featureCenter = new OpenLayers.Feature.Vector(center,null,centerStyle);
40    a_discLayer.addFeatures([featureDisc,featureCenter]);
41}
42
43// Draw line
44function osm_setLinePoints(a_tileLayer, a_lineLayer, a_strw, a_strcol, a_stropac, a_Points)
45{
46  var Points = new Array();
47
48  for (var i = 0; i < a_Points.length; i++) {
49   // var lonLat = new OpenLayers.LonLat(a_Points[i]["lon"], a_Points[i]["lat"]).transform(new OpenLayers.Projection("EPSG:4326"), a_tileLayer.getProjectionObject());
50   var lonLat = new OpenLayers.LonLat(a_Points[i]["lon"], a_Points[i]["lat"]).transform(a_tileLayer.displayProjection, a_tileLayer.projection);
51    Points[i] = new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat);
52  }
53  var line = new OpenLayers.Geometry.LineString(Points);
54  var style = { 
55    strokeColor: a_strcol, 
56    strokeOpacity: a_stropac, 
57    strokeWidth: a_strw 
58   };
59
60  var lineFeature = new OpenLayers.Feature.Vector(line, null, style);
61  a_lineLayer.addFeatures([lineFeature]);
62}
63
64
65// Clickhandler / Shorcode generator
66
67function osm_getIconSize(a_IconName){
68  Icon = new Object();
69  if (a_IconName.match('mic_')) {
70    Icon["height"] = "37";
71    Icon["width"] = "32";
72    Icon["offset_height"] = "-37";
73    Icon["offset_width"] = "-16";
74  }
75  else if (a_IconName.match('wpttemp')){
76    Icon["height"] = "24";
77    Icon["width"] = "24";
78    Icon["offset_height"] = "-24";
79    Icon["offset_width"] = "-0";
80  }
81  else if ((a_IconName == "camping.png") || (a_IconName == "friends.png") || (a_IconName == "guest_house.png") || (a_IconName == "home.png") || (a_IconName == "toilets.png")  || (a_IconName == "hotel.png")){
82    Icon["height"] = "32";
83    Icon["width"] = "32";
84    Icon["offset_height"] = "-16";
85    Icon["offset_width"] = "-16";
86  }
87  else if ((a_IconName == "hostel.png") || (a_IconName == "restaurant.png")){
88    Icon["height"] = "24";
89    Icon["width"] = "24";
90    Icon["offset_height"] = "-12";
91    Icon["offset_width"] = "-12";
92  }
93  else if (a_IconName == "marker_blue.png"){
94    Icon["height"] = "24";
95    Icon["width"] = "24";
96    Icon["offset_height"] = "-24";
97    Icon["offset_width"] = "0";
98  }
99  else if (a_IconName == "airport.png"){
100    Icon["height"] = "32";
101    Icon["width"] = "31";
102    Icon["offset_height"] = "-16";
103    Icon["offset_width"] = "-16";
104  }
105  else if (a_IconName == "bus.png"){
106    Icon["height"] = "32";
107    Icon["width"] = "26";
108    Icon["offset_height"] = "-16";
109    Icon["offset_width"] = "-13";
110  }
111  else if (a_IconName == "geocache.png"){
112    Icon["height"] = "25";
113    Icon["width"] = "25";
114    Icon["offset_height"] = "-12";
115    Icon["offset_width"] = "-12";
116  }
117  else if (a_IconName == "motorbike.png"){
118    Icon["height"] = "23";
119    Icon["width"] = "32";
120    Icon["offset_height"] = "-12";
121    Icon["offset_width"] = "-16";
122  }
123  else if (a_IconName == "services.png"){
124    Icon["height"] = "28";
125    Icon["width"] = "32";
126    Icon["offset_height"] = "-14";
127    Icon["offset_width"] = "-16";
128  }
129  else if (a_IconName == "styria_linux.png"){
130    Icon["height"] = "50";
131    Icon["width"] = "36";
132    Icon["offset_height"] = "-25";
133    Icon["offset_width"] = "-18";
134  }
135  else if (a_IconName == "marker_posts.png"){
136    Icon["height"] = "2";
137    Icon["width"] = "2";
138    Icon["offset_height"] = "-1";
139    Icon["offset_width"] = "-1";
140  }
141  else {
142    Icon["height"] = "32";
143    Icon["width"] = "32";
144    Icon["offset_height"] = "-16";
145    Icon["offset_width"] = "-16";
146  }
147  return Icon;
148}
149
150// Clickhandler / Shorcode generator
151
152function osm_getRadioValue(a_Form){
153  if (a_Form == "Markerform"){
154    for (var i=0; i < document.Markerform.Art.length; i++){
155      if (document.Markerform.Art[i].checked){
156        var rad_val = document.Markerform.Art[i].value;
157        return rad_val;
158      }
159    }
160    return "undefined";
161  }
162  else if (a_Form == "GPXcolourform"){
163    for (var i=0; i < document.GPXcolourform.Gpx_colour.length; i++){
164      if (document.GPXcolourform.Gpx_colour[i].checked){
165        var rad_val = document.GPXcolourform.Gpx_colour[i].value;
166        return rad_val;
167      }
168    }
169    return "undefined";
170  }
171  else if (a_Form == "Bordercolourform"){
172    for (var i=0; i < document.Bordercolourform.Border_colour.length; i++){
173      if (document.Bordercolourform.Border_colour[i].checked){
174        var rad_val = document.Bordercolourform.Border_colour[i].value;
175        return rad_val;
176      }
177    }
178    return "undefined";
179  }
180  else if (a_Form == "Naviform"){
181    for (var i=0; i < document.Naviform.Navi_Link.length; i++){
182      if (document.Naviform.Navi_Link[i].checked){
183        var rad_val = document.Naviform.Navi_Link[i].value;
184        return rad_val;
185      }
186    }
187    return "undefined";
188  }
189  else if (a_Form == "ControlStyleform"){
190    for (var i=0; i < document.ControlStyleform.Cntrl_style.length; i++){
191      if (document.ControlStyleform.Cntrl_style[i].checked){
192        var rad_val = document.ControlStyleform.Cntrl_style[i].value;
193        return rad_val;
194      }
195    }
196    return "undefined";
197  }
198  return "not implemented";
199}
200
201function osm_saveGeotag(){
202  if ((osm_ajax_object.lat == '') || (osm_ajax_object.lon == '')){
203    alert('Place geotag in the map before save');
204  }
205  else
206  {
207    var data = {
208      action: 'act_saveGeotag',
209      lat: osm_ajax_object.lat,
210      lon: osm_ajax_object.lon,
211      icon: osm_ajax_object.icon,
212      post_id: osm_ajax_object.post_id,
213      geotag_nonce: osm_ajax_object.geotag_nonce
214    };
215    jQuery.post(osm_ajax_object.ajax_url, data, function(response) {
216      div = document.getElementById("Geotag_Div");
217      div.innerHTML = response;
218    });
219  }
220}
221
222function osm_savePostMarker(){
223  if ((osm_ajax_object.MarkerLat == '') || (osm_ajax_object.MarkerLon == '')){
224    alert('Place marker in the map before save');
225  }
226  else
227  {
228    var data = {
229      action: 'act_saveMarker',
230      MarkerId: osm_ajax_object.MarkerId,
231      MarkerLat: osm_ajax_object.MarkerLat,
232      MarkerLon: osm_ajax_object.MarkerLon,
233      MarkerIcon: osm_ajax_object.MarkerIcon,
234      MarkerText: osm_ajax_object.MarkerText,
235      MarkerName: osm_ajax_object.MarkerName,
236      post_id: osm_ajax_object.post_id,
237      marker_nonce: osm_ajax_object.marker_nonce,
238    };
239    jQuery.post(osm_ajax_object.ajax_url, data, function(response) {
240      div = document.getElementById("Marker_Div");
241      div.innerHTML = response;
242    });
243  }
244}
245
246
247function getTileURL(bounds) {
248  var res = this.map.getResolution();
249  var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
250  var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
251  var z = this.map.getZoom();
252  var limit = Math.pow(2, z);
253  if (y < 0 || y >= limit) {
254    return null;
255  } 
256  else {
257    x = ((x % limit) + limit) % limit;
258    url = this.url;
259    path= z + "/" + x + "/" + y + "." + this.type;
260    if (url instanceof Array) {
261      url = this.selectUrl(path, url);
262    }
263    return url+path;
264  }
265}
266
267// http://trac.openlayers.org/changeset/9023
268function osm_getTileURL(bounds) {
269    var res = this.map.getResolution();
270    var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
271    var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
272    var z = this.map.getZoom();
273    var limit = Math.pow(2, z);
274
275    if (y < 0 || y >= limit) {
276        return OpenLayers.Util.getImagesLocation() + "404.png";
277    } else {
278        x = ((x % limit) + limit) % limit;
279        return this.url + z + "/" + x + "/" + y + "." + this.type;
280    }
281}
282
283
284function AddMarker(a_tileLayer, a_marker_distance)
285{
286    var ll;
287    var feature;
288    var marker;
289
290    var popup_maxwidth = 999;
291    var popup_maxheight = 250;
292
293    // Combine marker with a distance lower then 12 pixels
294    var PopUpArray = CombineNearMarker(a_marker_distance, a_tileLayer);
295
296    // Create marker
297    for (var i = 0; i < PopUpArray.length; i++)
298    {
299        // Convert coordinates
300        ll = new OpenLayers.LonLat(PopUpArray[i].Lon, PopUpArray[i].Lat).transform(a_tileLayer.displayProjection, a_tileLayer.projection);
301
302        // Create pop-up
303        feature = new OpenLayers.Feature(markers, ll, data);
304        feature.closeBox = true;
305        feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud,
306        {
307            "autoSize": true,
308            /*
309             * For "panMapIfOutOfView" and "keepInMap" see:
310             * http://permalink.gmane.org/gmane.comp.gis.openlayers.user/25702
311             */ 
312            "panMapIfOutOfView": false,
313            "keepInMap": false,
314            "contentDisplayClass": "olPopupContent",
315            maxSize: new OpenLayers.Size(popup_maxwidth, popup_maxheight)
316        });
317        //feature.data.overflow = "hidden";
318
319        // Create pop-up text
320        var TextArray = PopUpArray[i].Text;
321        var Text = 0;
322        for (var j = 0; j < TextArray.length; j++)
323        {
324        	if(j == 0)
325        	    Text = TextArray[j];
326        	else
327        		Text += "<br>" + TextArray[j];
328        }
329
330        feature.data.popupContentHTML = Text;
331
332        a_tileLayer.addPopup(feature.createPopup(feature.closeBox));
333        feature.popup.toggle();
334
335        // Create marker
336        if (PopUpArray[i].Count > 1) // If we have a combined marker than take an onther icon
337        {
338            marker = new OpenLayers.Marker(ll, data2.icon.clone());
339        }
340        else
341        {
342            marker = new OpenLayers.Marker(ll, data.icon.clone());
343        }
344
345        marker.feature = feature;
346        marker.events.register("mousedown", feature, markerClick);
347        markers.addMarker(marker);
348    }
349}
350
351function CombineNearMarker(PixelDiff, a_tileLayer)
352{
353    var px1 = a_tileLayer.getLonLatFromPixel(new OpenLayers.Pixel(0, 0));
354    var px2 = a_tileLayer.getLonLatFromPixel(new OpenLayers.Pixel(PixelDiff, 0));
355    var PixelLonLatDiff = Math.abs(px1.lon - px2.lon);
356
357    var PopUpArray = new Array();
358    var isNowPopUp = 0;
359
360    // Read all markers
361    for (var i = 0; i < MarkerArray.length; i++)
362    {
363        isNowPopUp = 0;
364
365        // Get the position of marker1 coordinates in pixel
366        var ll = new OpenLayers.LonLat(MarkerArray[i].Lon, MarkerArray[i].Lat).transform(a_tileLayer.displayProjection, a_tileLayer.projection);
367        var pixel = a_tileLayer.getPixelFromLonLat(ll);
368        var LonTemp1 = ll.lon;
369        var LatTemp1 = ll.lat;
370
371        // Use only the visible markers
372        if (pixel.x >= 0 && pixel.x <= a_tileLayer.size.w && pixel.y >= 0 && pixel.y <= a_tileLayer.size.h)
373        {
374            // Check if marker near to this marker exist
375            for (var j = 0; j < PopUpArray.length; j++)
376            {
377                // Get the position of marker2 coordinates in pixel
378                var ll = new OpenLayers.LonLat(PopUpArray[j].Lon, PopUpArray[j].Lat).transform(a_tileLayer.displayProjection, a_tileLayer.projection);
379                var LonTemp2 = ll.lon;
380                var LatTemp2 = ll.lat;
381
382                // Calculate difference of these two marker in pixel
383                var LonDiff = Math.abs(LonTemp1 - LonTemp2);
384                var LatDiff = Math.abs(LatTemp1 - LatTemp2);
385
386                // Check the distance
387                if (LonDiff <= PixelLonLatDiff && LatDiff <= PixelLonLatDiff)
388                {
389                    var Count = PopUpArray[j].Count;
390                    // Add this link to the existing marker
391                    PopUpArray[j].Text[Count] = MarkerArray[i].Text;
392                    // Calculate the mean position of these combined markers
393                    PopUpArray[j].Lat = (PopUpArray[j].Lat + MarkerArray[i].Lat) / 2;
394                    PopUpArray[j].Lon = (PopUpArray[j].Lon + MarkerArray[i].Lon) / 2;
395                    Count++;
396                    PopUpArray[j].Count = Count;
397                    isNowPopUp = 1;
398                }
399            }
400
401            // Add a new marker to the list
402            if (isNowPopUp == 0)
403            {
404                PopUpArray.push(
405                {
406                    Text: new Array(MarkerArray[i].Text),
407                    Lon: MarkerArray[i].Lon,
408                    Lat: MarkerArray[i].Lat,
409                    Count: 1
410                });
411            }
412        }
413    }
414
415    return PopUpArray;
416}
417
418document.addEventListener('DOMContentLoaded', function () {
419  // EventListener für Marker speichern und Shortcode generieren
420  const markerBtn = document.getElementById('osm-save-marker-btn');
421  if (markerBtn) {
422    markerBtn.addEventListener('click', function () {
423      osm_savePostMarker();
424      osm_generateAddMarkerSC();
425    });
426  }
427
428  // EventListener für Geotag speichern
429  const geotagBtn = document.getElementById('osm-save-geotag-btn');
430  if (geotagBtn) {
431    geotagBtn.addEventListener('click', function () {
432      osm_saveGeotag();
433    });
434  }
435  
436  // EventListener für generate File ShortCode
437  const FileSCBtn = document.getElementById('osm-gen-file-sc-btn');
438  if (FileSCBtn) {
439    FileSCBtn.addEventListener('click', function () {
440      osm_generateFileSC();
441    });
442  }
443  
444  // EventListener für generate tagged post ShortCode
445  const GenTPSCBtn = document.getElementById('osm-gen-tagged-post-sc-btn');
446  if (GenTPSCBtn) {
447    GenTPSCBtn.addEventListener('click', function () {
448      osm_generateTaggedPostsSC();
449    });
450  }
451  
452  const clusterRadio = document.getElementById('tagged_marker_cluster');
453  if (clusterRadio) {
454    clusterRadio.addEventListener('change', function () {
455      if (this.checked) {
456        osm_showTaggedSCmap();
457      }
458    });
459  }
460  
461  
462  const radios = document.querySelectorAll('input[name="tagged_marker_style"]');
463  radios.forEach(function (radio) {
464    radio.addEventListener('change', function () {
465      console.log("Marker Style gewählt:", this.value);
466      osm_showTaggedSCmap(); 
467    });
468  });
469  
470  const selectionBox = document.getElementById('show_selection_box');
471  if (selectionBox) {
472    selectionBox.addEventListener('change', function () {
473      osm_showFileSCmap();
474    });
475  }
476  
477});
478
479
480
481

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.