PageSourceSearch

https://www.colmcille.org/wp-content/plugins/modus-route-maps/js/openstreet/js/ol_leaflet_custom.js?ver=7.1.1

js colmcille.org collected 2026-09-25 01:57:35 UTC 17,565 bytes, 450 lines download raw bytes

1var attribution = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> MODUS';
2if (typeof getMapOpenStreetIcon !== "undefined" && getMapOpenStreetIcon != "") {
3    var icon_url = getMapOpenStreetIcon;
4
5    var map;
6    var startlat = jQuery('#latitude').val();
7    var startlon = jQuery('#longitude').val();
8    var options = {
9        center: [startlat, startlon],
10        zoom: 10
11    };
12    var address_textbox = jQuery('#address');
13
14    var map_icons = L.icon({
15        iconUrl: icon_url,
16        iconSize: [32, 32],
17        iconAnchor: [16, 32],
18        //shadowUrl: 'http://leafletjs.com/examples/custom-icons/leaf-shadow.png'
19    });
20
21    map = L.map('mapCanvas', options);
22    var nzoom = 12;
23
24    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: attribution}).addTo(map);
25
26    var myMarker = L.marker([startlat, startlon], {title: "Address", alt: "Address", draggable: true, icon: map_icons}).addTo(map).on('dragend', function () {
27        var lat = myMarker.getLatLng().lat.toFixed(8);
28        var lon = myMarker.getLatLng().lng.toFixed(8);
29        var czoom = map.getZoom();
30        if (czoom < 18) {
31            nzoom = czoom + 0.5;
32        }
33        if (nzoom > 18) {
34            nzoom = 18;
35        }
36        if (czoom != 18) {
37            map.setView([lat, lon], nzoom);
38        } else {
39            map.setView([lat, lon]);
40        }
41
42        jQuery('#latitude').val(lat);
43        jQuery('#longitude').val(lon);
44
45        jQuery.get('https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=' + lat + '&lon=' + lon, function (data) {
46            jQuery(address_textbox).val(data.address.road);
47        });
48
49        /* var address = jQuery('.address');
50         jQuery(address).on('click', function () {
51         myMarker.bindPopup("<b> Address : </b>" + jQuery(this).text()).openPopup();
52         jQuery(address_textbox).val(jQuery(this).text());
53         });*/
54    });
55}
56
57function getMapOpenStreet(icon_url) {
58    var map;
59    var startlat = jQuery('#latitude').val();
60    var startlon = jQuery('#longitude').val();
61    var options = {
62        center: [startlat, startlon],
63        zoom: 10
64    };
65    var address_textbox = jQuery('#address');
66
67    var map_icons = L.icon({
68        iconUrl: icon_url,
69        iconSize: [32, 32],
70        iconAnchor: [16, 32],
71        //shadowUrl: 'http://leafletjs.com/examples/custom-icons/leaf-shadow.png'
72    });
73
74
75    map = L.map('mapCanvas', options);
76    var nzoom = 12;
77
78    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: attribution}).addTo(map);
79
80    var myMarker = L.marker([startlat, startlon], {title: "Address", alt: "Address", draggable: true, icon: map_icons}).addTo(map).on('dragend', function () {
81        var lat = myMarker.getLatLng().lat.toFixed(8);
82        var lon = myMarker.getLatLng().lng.toFixed(8);
83        var czoom = map.getZoom();
84        if (czoom < 18) {
85            nzoom = czoom + 0.5;
86        }
87        if (nzoom > 18) {
88            nzoom = 18;
89        }
90        if (czoom != 18) {
91            map.setView([lat, lon], nzoom);
92        } else {
93            map.setView([lat, lon]);
94        }
95
96        jQuery('#latitude').val(lat);
97        jQuery('#longitude').val(lon);
98
99        jQuery.get('https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=' + lat + '&lon=' + lon, function (data) {
100            jQuery(address_textbox).val(data.address.road);
101        });
102
103        /* var address = jQuery('.address');
104         jQuery(address).on('click', function () {
105         myMarker.bindPopup("<b> Address : </b>" + jQuery(this).text()).openPopup();
106         jQuery(address_textbox).val(jQuery(this).text());
107         });*/
108    });
109}
110
111function chooseMapAddress(lat1, lng1) {
112    myMarker.closePopup();
113    map.setView([lat1, lng1], 10);
114    myMarker.setLatLng([lat1, lng1]);
115
116    lat = lat1.toFixed(8);
117    lon = lng1.toFixed(8);
118
119    //jQuery('#address').val('');
120    jQuery('#latitude').val(lat);
121    jQuery('#longitude').val(lon);
122
123    var address = jQuery('#results .address');
124    jQuery(address).on('click', function () {
125        myMarker.bindPopup("<b> Address : </b>" + jQuery(this).text()).openPopup();
126        jQuery('#address').val(jQuery(this).text());
127    });
128
129    //getMapOpenStreet('/wp-content/plugins/modus-route-maps/js/openstreet/images/marker-icon.png');
130}
131
132function viewMapResult(arr) {
133    var out = "<br />";
134    var i;
135
136    if (arr.length > 0) {
137        for (i = 0; i < arr.length; i++) {
138            out += "<div class='address' title='Show Location and Coordinates' onclick='chooseMapAddress(" + arr[i].lat + ", " + arr[i].lon + ");return false;'>" + arr[i].display_name + "</div>";
139        }
140        jQuery('#results').html(out);
141    } else {
142        jQuery('#results').html("Sorry, no results...");
143    }
144
145}
146
147jQuery(document).ready(function () {
148    jQuery('#address').keyup(function () {
149        var xmlhttp = new XMLHttpRequest();
150        //var url = "https://nominatim.openstreetmap.org/search?format=json&limit=10&q=" + jQuery('#address').val();
151        //Changes
152        var url = "https://nominatim.openstreetmap.org/search?format=json&countrycodes=ie,gb&limit=10&q=" + jQuery('#address').val();
153        xmlhttp.onreadystatechange = function () {
154            if (this.readyState == 4 && this.status == 200) {
155                var myArr = JSON.parse(this.responseText);
156                viewMapResult(myArr);
157            }
158        };
159        xmlhttp.open("GET", url, true);
160        xmlhttp.send();
161    });
162});
163
164
165
166function getMapMultiplePinOpenStreet(marker_div_id, map_box_access_key, locations, category_icon_url, route_color, route_type, fit_all_markers, map_lang, route_data_url, backend) {
167    var fileNameIndex = '';
168    var filename = '';
169    if (route_data_url != "" && typeof route_data_url !== "undefined") {
170        var fileNameIndex = route_data_url.lastIndexOf("/") + 1;
171        var filename = route_data_url.substr(fileNameIndex);
172    }
173
174    if (category_icon_url == "" || typeof category_icon_url == "undefined") {
175        category_icon_url = "";
176    }
177    if (route_color == "no") {
178        route_color = "";
179    } else if (route_color == "" || typeof route_color == "undefined") {
180        route_color = locations[0][6];
181    }
182
183    if (route_type == "" || typeof route_type == "undefined") {
184        route_type = locations[0][7];
185    }
186    /*if (route_type != "car" && route_type != "truck" && route_type != "small_truck" && route_type != "scooter" && route_type != "bike" && route_type != "mtb" && route_type != "racingbike" && route_type != "foot" && route_type != "hike") {
187     route_type = "car";
188     }*/
189    if (route_type != "driving" && route_type != "walking" && route_type != "cycling" && route_type != "driving-traffic") {
190        route_type = "driving";
191    }
192
193    var waypoints_array = [];
194    var linepoints_array = [];
195    var routing_waypoints_array = [];
196
197    var map;
198    var options = {
199        center: [locations[locations.length - 1][2], locations[locations.length - 1][3]],
200        zoom: 10,
201        fullscreenControl: true,
202    };
203
204    //map = L.map('mapCanvas', options);
205    map = L.map(marker_div_id, options);
206    if (map_lang == 'french') {
207        L.tileLayer('https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', {attribution: attribution}).addTo(map);
208    } else if (map_lang == 'dutch') {
209        L.tileLayer('https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png', {attribution: attribution}).addTo(map);
210    } else if (map_lang == 'irish') {
211        //L.tileLayer('http://{s}.tile.openstreetmap.ga/osmga/{z}/{x}/{y}.png').addTo(map);
212        //L.tileLayer('http://{s}.tile.openstreetmap.ga/{z}/{x}/{y}.png', {attribution: 'OSM'}).addTo(map);
213        //L.tileLayer('http://{s}.tile.osm.ga/{z}/{x}/{y}.png', {attribution: 'OSM'}).addTo(map);  //TEMP LASTING TESTING
214        /////
215        //L.tileLayer('http://{s}.tile.openstreetmap.gd/osmgd/{z}/{x}/{y}.png', {attribution: 'OSM'}).addTo(map);
216        //L.tileLayer('http://{s}.tile.openstreetmap.gd/{z}/{x}/{y}.png', {attribution: 'OSM'}).addTo(map);
217        //L.tileLayer('http://{s}.tile.osm.gd/{z}/{x}/{y}.png', {attribution: 'OSM'}).addTo(map);
218
219        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: attribution}).addTo(map);
220    } else {
221        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: attribution}).addTo(map);
222    }
223
224    for (i = 0; i < locations.length; i++) {
225        waypoints_array.push(L.latLng(locations[i][2], locations[i][3]));
226        linepoints_array.push([locations[i][2], locations[i][3]]);
227
228        var target = L.latLng(locations[i][2], locations[i][3]);
229        var link = locations[i][8];
230
231        // Set map's center to target with zoom 14.
232        map.setView(target, 10);
233
234        var icon_url = locations[i][5];
235        if (icon_url == "" || typeof icon_url == "undefined") {
236            icon_url = category_icon_url;
237        }
238
239        if (icon_url != "") {
240            var map_icons = L.icon({
241                iconUrl: icon_url,
242                iconSize: [32, 32],
243                iconAnchor: [16, 32],
244                //shadowUrl: 'http://leafletjs.com/examples/custom-icons/leaf-shadow.png'
245            });
246            // Place a marker on the same location.
247            // Changes Start
248            //L.marker(target, {icon: map_icons}).addTo(map);
249            L.marker(target, {icon: map_icons}).addTo(map).bindPopup('<a href="' + link + '">' + locations[i][1] + '</a>').on('mouseover', function (ev) {
250                this.openPopup();
251            });
252            // Changes End
253        } else {
254            //L.marker(target).addTo(map);
255            L.marker(target).addTo(map).bindPopup('<a href="' + link + '" >' + locations[i][1] + '</a>').on('mouseover', function (ev) {
256                this.openPopup();
257            });
258
259        }
260        if (fit_all_markers == 'yes') {
261            var bounds = L.latLngBounds(waypoints_array);
262            map.fitBounds(bounds);
263        }
264    }
265
266    var map_file_exists_flag = checkMapfileExists(route_data_url);
267
268    console.log("route_color " + route_color);
269    console.log("route_data_url " + route_data_url);
270    console.log("route_backend " + backend);
271    console.log("Map File Flag " + map_file_exists_flag);
272
273    if (map_file_exists_flag == true) {  // && backend == 0
274        jQuery.get(route_data_url, function (textData) {
275            //console.log("Map Json Data " + jQuery.parseJSON('[' + textData + ']'));
276            var myLines = [{
277                    "type": "LineString",
278                    "coordinates": jQuery.parseJSON('[' + textData + ']')
279                }];
280
281            var myStyle = {
282                "color": route_color,
283                "weight": 5,
284                //"dashArray": '5 5',
285                "opacity": 1
286            };
287
288            if (backend == 1) {
289                var geojsonLayer = L.geoJSON(myLines, {
290                    style: myStyle,
291                    onEachFeature: function (f, l) {
292                        l.bindPopup('saved route');
293                    }
294                }).addTo(map).openPopup();
295
296                /*L.Routing.control({
297                 routeWhileDragging: true,
298                 }).addTo(map);*/
299            } else {
300                var geojsonLayer = L.geoJSON(myLines, {
301                    style: myStyle
302                }).addTo(map);
303            }
304            map.fitBounds(geojsonLayer.getBounds());
305        }).fail(function () {
306            console.log("no saved route found");
307        });
308
309        if (backend == 1) {
310            var control = L.Routing.control({
311                waypoints: waypoints_array,
312                lineOptions: {
313                    styles: [{color: 'blue', opacity: 1, weight: 5}]
314                },
315                routeWhileDragging: true,
316                show: false,
317                createMarker: function () {
318                    return null;
319                },
320
321                router: L.Routing.mapbox(map_box_access_key, {//'pk.eyJ1IjoidGVzdGl3bTAwNyIsImEiOiJja251NXhiZjEwODl2Mm9tbTRnN2x0NWM4In0.dobMp_ and so on'
322                    profile: 'mapbox/' + route_type //driving //walking //cycling
323                })
324            }).addTo(map);
325        }
326    } else {
327        var control = L.Routing.control({
328            waypoints: waypoints_array,
329            lineOptions: {
330                styles: [{color: route_color, opacity: 1, weight: 5}]
331            },
332            routeWhileDragging: true,
333            show: false,
334            createMarker: function () {
335                return null;
336            },
337
338            router: L.Routing.mapbox(map_box_access_key, {//'pk.eyJ1IjoidGVzdGl3bTAwNyIsImEiOiJja251NXhiZjEwODl2Mm9tbTRnN2x0NWM4In0.dobMp_ and so on'
339                profile: 'mapbox/' + route_type //driving //walking //cycling
340            })
341        }).addTo(map);
342        /*if (filename != "" && typeof filename !== "undefined") {
343         control.on('routeselected', function (e) {
344         var coord = e.route.coordinates;
345         var instr = e.route.instructions;
346         for (i = 0; i < coord.length; i++) {
347         var lat = coord[i].lat;
348         var lng = coord[i].lng;
349         routing_waypoints_array.push('[' + lng + ',' + lat + ']');
350         
351         }
352         jQuery.ajax(
353         {
354         url: ajaxurl,
355         data: {action: "mapRoutesSaveTextFile", data: routing_waypoints_array, file_name: filename},
356         type: 'POST',
357         success: function (response) {
358         //console.log("call" + JSON.stringify(response, true));
359         },
360         error: function (xhr, ajaxOptions, thrownError) {
361         //console.log(xhr.status);
362         },
363         });
364         });
365         }*/
366    }
367
368    if (backend == 1) {
369        control.on('routeselected', function (e) {
370            currentRoute = e;
371        });
372    }
373    //console.log("Map WayPoints " + waypoints_array);
374
375    if (map_file_exists_flag == false && backend == 0) {
376        console.log("No route found!");
377    }
378
379    if (filename != "" && typeof filename !== "undefined" && backend == 1) {
380        var currentRoute;
381        var customControl = L.Control.extend({
382
383            options: {
384                position: 'bottomleft'
385            },
386
387            onAdd: function (map) {
388                var container = L.DomUtil.create('input');
389                container.type = "button";
390                container.title = "Route";
391                container.value = "Save";
392                //container.style.backgroundColor = 'white';
393                //container.style.backgroundSize = "40px 30px";
394                //container.style.width = '40px';
395                //container.style.height = '30px';
396                container.onmouseover = function () {
397                    container.style.backgroundColor = 'red';
398                }
399                container.onmouseout = function () {
400                    container.style.backgroundColor = 'white';
401                }
402                container.onclick = function () {
403                    var coord = currentRoute.route.coordinates;
404                    var instr = currentRoute.route.instructions;
405                    console.log("Map Route Coordinates Count " + co
405ord.length);
406                    for (i = 0; i < coord.length; i++) {
407                        var lat = coord[i].lat;
408                        var lng = coord[i].lng;
409                        routing_waypoints_array.push('[' + lng + ',' + lat + ']');
410                    }
411                    console.log("Map Route Coordinates Array " + routing_waypoints_array);
412                    jQuery.ajax(
413                            {
414                                url: ajaxurl,
415                                data: {action: "mapRoutesSaveTextFile", data: routing_waypoints_array, file_name: filename},
416                                type: 'POST',
417                                success: function (response) {
418                                    if (response != "") {
419                                        window.alert("Route saved");
420                                    } else {
421                                        window.alert("Route not saved");
422                                    }
423                                },
424                                error: function (xhr, ajaxOptions, thrownError) {
425                                    console.log("Map File Save Error " + xhr.status);
426                                },
427                            });
428                }
429                return container;
430            }
431        });
432        map.addControl(new customControl());
433        jQuery('.leaflet-bottom .leaflet-control').addClass('button');
434        jQuery('.leaflet-bottom .leaflet-control.button').parent().addClass('leaflet-button');
435    }
436
437    //var polyline = L.polyline(linepoints_array, {color: route_color, opacity: 1, weight: 5}).addTo(map);
438
439    jQuery('.leaflet-routing-container').hide();
440}
441function checkMapfileExists(url) {
442    if (url) {
443        var req = new XMLHttpRequest();
444        req.open('GET', url, false);
445        req.send();
446        return req.status == 200;
447    } else {
448        return false;
449    }
450}

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.