PageSourceSearch

https://www.cateringbeet.be/sites/all/modules/getlocations/modules…/js/getlocations_leaflet.js?v=7.x-1.x

js cateringbeet.be collected 2026-10-08 01:46:14 UTC 29,103 bytes, 708 lines download raw bytes

1
2/**
3 * @file
4 * getlocations_leaflet.js
5 * @author Bob Hutchinson http://drupal.org/user/52366
6 * @copyright GNU GPL
7 *
8 * Javascript functions for getlocations_leaflet module for Drupal 7
9 * this is for leaflet maps http://leafletjs.com/
10 */
11
12(function ($) {
13  Drupal.getlocations_leaflet = {};
14  Drupal.getlocations_leaflet_map = [];
15  Drupal.getlocations_leaflet_markers = [];
16  Drupal.getlocations_leaflet_settings = [];
17  Drupal.getlocations_leaflet_overlays = [];
18  Drupal.getlocations_leaflet_layerscontrol = [];
19  Drupal.getlocations_leaflet_data = [];
20  Drupal.getlocations_leaflet_geocoder = [];
21
22  Drupal.behaviors.getlocations_leaflet = {
23    attach: function (context, settings) {
24
25      // functions
26
27      function getlocations_leaflet_do_link(m, l) {
28        m.on('click', function() {
29          window.location = l;
30        });
31      }
32
33      // show_maplinks
34      function getlocations_leaflet_show_maplinks(key, glid, m, a) {
35        $("div#getlocations_leaflet_map_links_" + key + " ul").append('<li><a href="#maptop_' + key + '" class="glid-' + glid + '">' + m.options.title + '</a></li>');
36        $("div#getlocations_leaflet_map_links_" + key + " a.glid-" + glid).click(function() {
37          $("div#getlocations_leaflet_map_links_" + key + " a").removeClass('active');
38          $("div#getlocations_leaflet_map_links_" + key + " a.glid-" + glid).addClass('active');
39          if (a.type == 'link') {
40            // relocate
41            window.location = a.data;
42          }
43          else if (a.type == 'popup') {
44            m.fire('click');
45          }
46        });
47      }
48
49      function getlocations_leaflet_deactive_throbber(k) {
50        $("#getlocations_leaflet_gps_throbber_" + k).removeClass('getlocations_leaflet_gps_throbber_active');
51        $("#getlocations_leaflet_gps_throbber_" + k).addClass('getlocations_leaflet_gps_throbber_inactive');
52      }
53
54      // end functions
55
56      // work over all class 'getlocations_leaflet_canvas'
57      $(".getlocations_leaflet_canvas", context).once('getlocations-leaflet-processed', function(index, element) {
58        var elemID = $(element).attr('id');
59        var key = elemID.replace(/^getlocations_leaflet_canvas_/, '');
60        // is there really a map?
61        if ( $("#getlocations_leaflet_canvas_" + key).is('div') ) {
62          var map_settings = settings.getlocations_leaflet[key].map_settings;
63          var map_opts = settings.getlocations_leaflet[key].map_opts;
64          var map_layers = settings.getlocations_leaflet[key].map_layers;
65
66          var icons = Drupal.getlocations_leaflet_data[key].icons;
67          var datanum = Drupal.getlocations_leaflet_data[key].datanum;
68          var latlons = Drupal.getlocations_leaflet_data[key].latlons;
69
70          Drupal.getlocations_leaflet_markers[key] = {};
71          Drupal.getlocations_leaflet_markers[key].coords = {};
72          Drupal.getlocations_leaflet_markers[key].lids = {};
73          Drupal.getlocations_leaflet_markers[key].cat = {};
74          Drupal.getlocations_leaflet_settings[key] = settings.getlocations_leaflet[key];
75          Drupal.getlocations_leaflet_overlays[key] = {};
76          Drupal.getlocations_leaflet_layerscontrol[key] = {};
77
78          // get the map
79          //Drupal.getlocations_leaflet_map[key] = L.map('getlocations_leaflet_canvas_' + key, map_opts);
80          Drupal.getlocations_leaflet_map[key] = L.map($(element).get(0), map_opts);
81
82          // layers
83          var layers = {};
84          var gotmap = false;
85
86          // mapquest
87          if (map_settings.mapquest_key && typeof(MQ) !== 'undefined') {
88
89            if (map_settings.mapquest_traffic_enable) {
90              if (map_settings.mapquest_traffic_flow) {
91                var label_flow = Drupal.t('Traffic Flow');
92                Drupal.getlocations_leaflet_overlays[key][label_flow] = MQ.trafficLayer({layers: ['flow']});
93                if (map_settings.mapquest_traffic_flow_on == 1) {
94                  Drupal.getlocations_leaflet_overlays[key][label_flow].addTo(Drupal.getlocations_leaflet_map[key]);
95                }
96              }
97              if (map_settings.mapquest_traffic_incident) {
98                var label_incident = Drupal.t('Traffic Incidents');
99                Drupal.getlocations_leaflet_overlays[key][label_incident] = MQ.trafficLayer({layers: ['incidents']});
100                if (map_settings.mapquest_traffic_incident_on == 1) {
101                  Drupal.getlocations_leaflet_overlays[key][label_incident].addTo(Drupal.getlocations_leaflet_map[key]);
102                }
103              }
104            }
105
106            if (map_settings.mapquest_routing_enable) {
107            }
108
109            if (map_settings.mapquest_geocoder_enable) {
110            }
111
112            if (map_settings.mapquest_maps_enable && map_settings.mapquest_maps_use) {
113              var default_layer_name = MQ.mapLayer();
114              var default_layer_label = Drupal.t('Map layer');
115              if (map_settings.mapquest_maps_default == 's') {
116                default_layer_name = MQ.satelliteLayer();
117                default_layer_label = Drupal.t('Satellite layer');
118              }
119              else if (map_settings.mapquest_maps_default == 'h') {
120                default_layer_name = MQ.hybridLayer();
121                default_layer_label = Drupal.t('Hybrid layer');
122              }
123              layers[default_layer_label] = default_layer_name.addTo(Drupal.getlocations_leaflet_map[key]);
124              if (map_settings.mapquest_maps_default != 'm' && map_settings.mapquest_maps_maplayer) {
125                layers[Drupal.t('Map layer')] = MQ.mapLayer();
126              }
127              if (map_settings.mapquest_maps_default != 's' && map_settings.mapquest_maps_satellitelayer) {
128                layers[Drupal.t('Satellite layer')] = MQ.satelliteLayer();
129              }
130              if (map_settings.mapquest_maps_default != 'h' && map_settings.mapquest_maps_hybridlayer) {
131                layers[Drupal.t('Hybrid layer')] = MQ.hybridLayer();
132              }
133              gotmap = true;
134            }
135
136          }
137
138          if (! gotmap) {
139            // do the default layer first and separately
140            var default_layer_name = map_settings.default_layer_name;
141            var default_layer_label = map_settings.default_layer_label;
142            layers[default_layer_label] = L.tileLayer.provider(default_layer_name).addTo(Drupal.getlocations_leaflet_map[key]);
143            for (var lkey in map_layers) {
144              if (lkey != default_layer_name) {
145                var layer = map_layers[lkey];
146                var map_layer = L.tileLayer.provider(lkey);
147                map_layer._leaflet_id = lkey;
148                if (layer.options) {
149                  for (var option in layer.options) {
150                    map_layer.options[option] = layer.options[option];
151                  }
152                }
153                if (layer.type == 'base') {
154                  layers[layer.label] = map_layer;
155                }
156                else if (layer.type == 'overlay') {
157                  Drupal.getlocations_leaflet_overlays[key][layer.label] = map_layer;
158                }
159              }
160            }
161
162          }
163
164          if (layers.length) {
165            layers.addTo(Drupal.getlocations_leaflet_map[key]);
166          }
167
168          // fullscreen control
169          if (map_settings.fullscreen) {
170            var fsopts = {};
171            if (map_settings.fullscreenposition) {
172              fsopts.position = map_settings.fullscreenposition;
173            }
174            fsopts.title = Drupal.t('Fullscreen');
175            Drupal.getlocations_leaflet_map[key].addControl(L.control.fullscreen(fsopts));
176          }
177
178          // magnifying glass
179          if (map_settings.magnifyingglass) {
180            var la =  L.tileLayer.provider(map_settings.default_layer_name);
181            var magOpts = {
182              zoomOffset: parseInt(map_settings.magnifyingglasszoomoffset),
183              radius: parseInt(map_settings.magnifyingglassradius),
184              fixedPosition: false,
185              latLng: [0, 0],
186              fixedZoom: -1,
187              layers: [L.tileLayer(la._url, la.options)]
188            };
189            var magnifyingGlass = L.magnifyingGlass(magOpts);
190            var magControlOpts = {
191              forceSeparateButton: false,
192              title: Drupal.t('Magnifying Glass'),
193              position: (map_settings.magnifyingglasscontrolposition ? map_settings.magnifyingglasscontrolposition : 'topleft')
194            };
195            Drupal.getlocations_leaflet_map[key].addControl(L.control.magnifyingglass(magnifyingGlass, magControlOpts));
196          }
197
198          // pancontrol
199          if (map_settings.leaflet_pancontrol) {
200            var popts = {};
201            if (map_settings.pancontrolposition) {
202              popts.position = map_settings.pancontrolposition;
203            }
204            Drupal.getlocations_leaflet_map[key].addControl(L.control.pan(popts));
205          }
206
207          // zoomslider
208          if (map_settings.leaflet_zoomslider) {
209            var popts = {};
210            if (map_settings.zoomsliderposition) {
211              popts.position = map_settings.zoomsliderposition;
212            }
213            Drupal.getlocations_leaflet_map[key].addControl(L.control.zoomslider(popts));
214          }
215
216          // graticule
217          if (map_settings.graticule) {
218            var gropts = {};
219            gropts.style = {};
220            if (map_settings.graticule_color) {
221              gropts.style.color = map_settings.graticule_color;
222            }
223            if (map_settings.graticule_opacity) {
224              gropts.style.opacity = map_settings.graticule_opacity;
225            }
226            if (map_settings.graticule_weight) {
227              gropts.style.weight = map_settings.graticule_weight;
228            }
229            if (map_settings.graticule_interval) {
230              gropts.interval = parseInt(map_settings.graticule_interval);
231            }
232            var graticule = L.graticule(gropts);
233
234            if (map_settings.graticule_show == 2) {
235              var gratctlOpts = {
236                forceSeparateButton: false,
237                title: map_settings.graticule_ov_label,
238                position: (map_settings.graticule_position ? map_settings.graticule_position : 'topleft')
239              };
240              Drupal.getlocations_leaflet_map[key].addControl(L.control.graticule(graticule, gratctlOpts));
241            }
242            if ((map_settings.graticule_show && map_settings.graticule_state) || (! map_settings.graticule_show)) {
243              graticule.addTo(Drupal.getlocations_leaflet_map[key]);
244            }
245          }
246
247          // Terminator or Day/Night
248          if (map_settings.terminator) {
249            if (! map_settings.terminator_strokecolor.match(/^#/)) {
250              map_settings.terminator_strokecolor = '#' + map_settings.terminator_strokecolor;
251            }
252            if (! map_settings.terminator_fillcolor.match(/^#/)) {
253              map_settings.terminator_fillcolor = '#' + map_settings.terminator_fillcolor;
254            }
255            var terminatorOpts = {
256              color: map_settings.terminator_strokecolor,
257              opacity: map_settings.terminator_strokeopacity,
258              weight: parseInt(map_settings.terminator_strokeweight),
259              fillColor: map_settings.terminator_fillcolor ,
260              fillOpacity: map_settings.terminator_fillopacity,
261              resolution: 2
262            };
263            var terminator = L.terminator(terminatorOpts);
264            if (map_settings.terminator_show == 2) {
265              var termctlOpts = {
266                forceSeparateButton: false,
267                title: map_settings.terminator_label,
268                position: (map_settings.terminator_position ? map_settings.terminator_position : 'topleft')
269              };
270              Drupal.getlocations_leaflet_map[key].addControl(L.control.terminator(terminator, termctlOpts));
271            }
272            if ((map_settings.terminator_show && map_settings.terminator_state) || (! map_settings.terminator_show)) {
273              terminator.addTo(Drupal.getlocations_leaflet_map[key]);
274            }
275          }
276
277          // Zoom control
278          if (map_settings.zoomControl) {
279            var zoomopts = {};
280            if (map_settings.zoomcontrolposition) {
281              zoomopts.position = map_settings.zoomcontrolposition;
282            }
283            Drupal.getlocations_leaflet_map[key].addControl(L.control.zoom(zoomopts));
284          }
285
286          // Attribution control
287          if (map_settings.attributionControl && map_settings.attributioncontrolposition) {
288            var attributionopts = {position: map_settings.attributioncontrolposition};
289            var attribcontrol = L.control.attribution(attributionopts);
290            Drupal.getlocations_leaflet_map[key].addControl(attribcontrol);
291            //attribcontrol.addAttribution(map_layers.earth.options.attribution);
292          }
293
294          // Mouseposition
295          if (map_settings.mouseposition) {
296            var mopts = {};
297            mopts.emptystring = Drupal.t('Unavailable');
298            if (map_settings.mouseposition_position) {
299              mopts.position = map_settings.mouseposition_position;
300            }
301            if (map_settings.mouseposition_display_dms) {
302              mopts.lngFormatter = Drupal.getlocations.geo.dd_to_dms_lng;
303              mopts.latFormatter = Drupal.getlocations.geo.dd_to_dms_lat;
304            }
305            else {
306              mopts.lngFormatter = Drupal.getlocations.geo.dd_lng;
307              mopts.latFormatter = Drupal.getlocations.geo.dd_lat;
308            }
309            Drupal.getlocations_leaflet_map[key].addControl(L.control.mousePosition(mopts));
310          }
311
312          // Scale control
313          if (map_settings.scaleControl) {
314            var scaleopts = {};
315            if (map_settings.scalecontrolposition) {
316              scaleopts.position = map_settings.scalecontrolposition;
317            }
318            if (map_settings.scalecontrolunits) {
319              if (map_settings.scalecontrolunits == 'metric') {
320                scaleopts.metric = true;
321                scaleopts.imperial = false;
322              }
323              else if (map_settings.scalecontrolunits == 'imperial') {
324                scaleopts.metric = false;
325                scaleopts.imperial = true;
326              }
327            }
328            Drupal.getlocations_leaflet_map[key].addControl(L.control.scale(scaleopts));
329          }
330
331          // Geocoder control
332          if (map_settings.geocoder) {
333            var geo_opts = {};
334            geo_opts.placeholder = map_settings.geocoder_placeholder;
335            geo_opts.errorMessage = map_settings.geocoder_errormessage;
336            geo_opts.collapsed = (map_settings.geocodercollapsed ? true : false);
337            if (map_settings.geocoderposition) {
338              geo_opts.position = map_settings.geocoderposition;
339            }
340            if (map_settings.geocodersrc == 'b' && map_settings.geocoder_bing_key) {
341              geo_opts.geocoder = L.Control.Geocoder.bing(map_settings.geocoder_bing_key);
342              var geocoder_msg = Drupal.t('Geocoding by Bing');
343            }
344            else if (map_settings.geocodersrc == 'm' && map_settings.mapquest_key) {
345              geo_opts.geocoder = L.Control.Geocoder.mapQuest(map_settings.mapquest_key);
346              var geocoder_msg = Drupal.t('Geocoding by MapQuest');
347            }
348            else if (map_settings.geocodersrc == 'x' && map_settings.geocoder_mapbox_key) {
349              geo_opts.geocoder = L.Control.Geocoder.mapbox(map_settings.geocoder_mapbox_key);
350              var geocoder_msg = Drupal.t('Geocoding by Mapbox');
351            }
352            else if (map_settings.geocodersrc == 'g' && map_settings.geocoder_google_key) {
353              geo_opts.geocoder = L.Control.Geocoder.google(map_settings.geocoder_google_key);
354              var geocoder_msg = Drupal.t('Geocoding by Google');
355            }
356            else {
357              geo_opts.geocoder = L.Control.Geocoder.nominatim();
358              var geocoder_msg = Drupal.t('Geocoding by Nominatim');
359            }
360            Drupal.getlocations_leaflet_geocoder[key] = L.Control.geocoder(geo_opts);
361            Drupal.getlocations_leaflet_map[key].addControl(Drupal.getlocations_leaflet_geocoder[key]);
362            $(".leaflet-control-geocoder .leaflet-control-geocoder-icon").attr({title: geocoder_msg});
363          }
364
365          // latlons data
366          if (datanum > 0) {
367
368            // categories
369            var categories = {};
370            if (map_settings.category_showhide_buttons) {
371              categories = (map_settings.categories ? map_settings.categories : {});
372            }
373
374            // markers
375            var Markers = [];
376            if (map_settings.markercluster) {
377              if (map_settings.category_showhide_buttons) {
378                for (var c in categories) {
379                  Markers[c] = L.markerClusterGroup(map_settings.markerclusteroptions);
380                }
381              }
382              else {
383                Markers['loc'] = L.markerClusterGroup(map_settings.markerclusteroptions);
384              }
385            }
386            else {
387              if (map_settings.category_showhide_buttons) {
388                for (var c in categories) {
389                  Markers[c] = L.layerGroup();
390                }
391              }
392              else {
393                Markers['loc'] = L.layerGroup();
394              }
395            }
396
397            // loop over latlons
398            for (var i = 0; i < latlons.length; i++) {
399              var latlon = latlons[i];
400              var lat           = latlon[0];
401              var lon           = latlon[1];
402              var entity_key    = latlon[2];
403              var entity_id     = latlon[3];
404              var glid          = latlon[4];
405              var title         = latlon[5];
406              var markername    = latlon[6];
407              var vector        = latlon[7];
408              var markeraction  = latlon[8];
409              var cat           = latlon[9];
410              var icon = '';
411              if (markername) {
412                icon = icons[markername];
413              }
414
415              // get the marker
416              Marker = Drupal.getlocations_leaflet.makeMarker(map_settings, lat, lon, entity_key, entity_id, glid, title, icon, vector, markeraction, cat, key);
417
418              // add the marker to the group(s)
419              if (map_settings.category_showhide_buttons && cat) {
420                for (var c in categories) {
421                  if (cat == c) {
422                    Markers[c].addLayer(Marker);
423                  }
424                }
425              }
426              else {
427                Markers['loc'].addLayer(Marker);
428              }
429
430              // show_maplinks
431              if (markeraction && markeraction.type && markeraction.data) {
432                if (title && map_settings.show_maplinks) {
433                  getlocations_leaflet_show_maplinks(key, glid, Marker, markeraction);
434                }
435              }
436
437              // add marker to getlocations_leaflet_markers
438              // still experimental
439              Drupal.getlocations_leaflet_markers[key].lids[glid] = Marker;
440
441            } // end latlons
442
443            // add the markers to the map
444            if (map_settings.category_showhide_buttons) {
445              for (var c in categories) {
446                Drupal.getlocations_leaflet_map[key].addLayer(Markers[c]);
447              }
448            }
449            else {
450              Drupal.getlocations_leaflet_map[key].addLayer(Markers['loc']);
451            }
452
453            // set up overlays
454            if (map_settings.category_showhide_buttons) {
455              for (var c in categories) {
456                Drupal.getlocations_leaflet_overlays[key][categories[c]] = Markers[c];
457              }
458            }
459            else if (map_settings.layercontrol_mark_ov) {
460              Drupal.getlocations_leaflet_overlays[key][map_settings.layercontrol_mark_ov_label] = Markers['loc'];
461            }
462
463            // adding graticule to overlay switches
464            if (map_settings.graticule && map_settings.graticule_show == 1 ) {
465              Drupal.getlocations_leaflet_overlays[key][map_settings.graticule_ov_label] = graticule;
466            }
467
468            // adding terminator to overlay switches
469            if (map_settings.terminator && map_settings.terminator_show == 1 ) {
470              Drupal.getlocations_leaflet_overlays[key][map_settings.terminator_label] = terminator;
471            }
472
473          } // end datanum > 0
474
475          // Layer control
476          if (map_settings.layerControl) {
477            var layeropts = {};
478            if (map_settings.layercontrolposition) {
479              layeropts.position = map_settings.layercontrolposition;
480            }
481            if (map_settings.minimap) {
482              Drupal.getlocations_leaflet_layerscontrol[key] = L.control.layers.minimap(layers, Drupal.getlocations_leaflet_overlays[key], layeropts).addTo(Drupal.getlocations_leaflet_map[key]);
483            }
484            else {
485              Drupal.getlocations_leaflet_layerscontrol[key] = L.control.layers(layers, Drupal.getlocations_leaflet_overlays[key], layeropts).addTo(Drupal.getlocations_leaflet_map[key]);
486            }
487          }
488
489          // bounds
490          Drupal.getlocations_leaflet.redoMap(key);
491
492          // Usermarker
493          if (map_settings.usermarker) {
494            var usermarker = null;
495            $("#getlocations_leaflet_gps_show_" + key).click( function() {
496              $("#getlocations_leaflet_gps_throbber_" + key).removeClass('getlocations_leaflet_gps_throbber_inactive');
497              $("#getlocations_leaflet_gps_throbber_" + key).addClass('getlocations_leaflet_gps_throbber_active');
498              if (usermarker) {
499                Drupal.getlocations_leaflet_map[key].removeLayer(usermarker);
500                usermarker = null;
501              }
502              Drupal.getlocations_leaflet_map[key].on("locationfound", function(location) {
503                if (! usermarker) {
504                  usermarker_opts = {
505                    pulsing: map_settings.usermarker_pulsing,
506                    smallIcon: map_settings.usermarker_smallicon,
507                    circleOpts: {
508                      stroke: map_settings.usermarker_circle_stroke,
509                      color: map_settings.usermarker_circle_strokecolor,
510                      weight: map_settings.usermarker_circle_strokeweight,
511                      opacity: map_settings.usermarker_circle_strokeopacity,
512                      fillOpacity: map_settings.usermarker_circle_fillopacity,
513                      fillColor: map_settings.usermarker_circle_fillcolor,
514                      clickable: false
515                    }
516                  };
517                  usermarker = L.userMarker(location.latlng, usermarker_opts).addTo(Drupal.getlocations_leaflet_map[key]);
518                  usermarker.setLatLng(location.latlng);
519                  if (map_settings.usermarker_accuracy) {
520                    usermarker.setAccuracy(location.accuracy);
521                  }
522                }
523                getlocations_leaflet_deactive_throbber(key);
524              });
525              Drupal.getlocations_leaflet_map[key].on("locationerror", function(error) {
526                getlocations_leaflet_deactive_throbber(key);
527                alert(Drupal.t('Error: location failed.') + ' ' + error.message);
528              });
529
530              Drupal.getlocations_leaflet_map[key].locate({
531                watch: false,
532                locate: true,
533                setView: true,
534                enableHighAccuracy: true
535              });
536
537            });
538
539          }
540
541          // leaflet hash
542          if (map_settings.hashurl && typeof(L.Hash) !== 'undefined') {
543            L.hash(Drupal.getlocations_leaflet_map[key]);
544          }
545
546          // show_maplinks_viewport
547          if (map_settings.show_maplinks && map_settings.show_maplinks_viewport) {
548            Drupal.getlocations_leaflet_map[key].on('moveend zoomend', function() {
549              var b = Drupal.getlocations_leaflet_map[key].getBounds();
550              for (var i = 0; i < latlons.length; i++) {
551                var latlon = latlons[i];
552                var lat = latlon[0];
553                var lon = latlon[1];
554                var glid = latlon[4];
555                var p = L.latLng(lat, lon);
556                if (b.contains(p)) {
557                  // hide and show the links for markers in the current viewport
558                  $("li a.glid-" + glid).show();
559                }
560                else {
561                  $("li a.glid-" + glid).hide();
562                }
563              }
564            });
565          }
566
567        } // end is there really a map?
568      }); // end once
569    } // end attach
570  }; // end behaviors
571
572
573  // external functions
574  Drupal.getlocations_leaflet.makeMarker = function(gs, lat, lon, entity_key, entity_id, glid, title, icon, vector, markeraction, cat, mkey) {
575
576    // categories
577    if (cat) {
578      Drupal.getlocations_leaflet_markers[mkey].cat[glid] = cat;
579    }
580
581    var vicon = false;
582    if (typeof(vector.data) !== undefined) {
583      vicon = vector.data;
584      var marker_type = vector.type;
585    }
586
587    // check for duplicates
588    var hash = new String(lat + lon);
589    if (Drupal.getlocations_leaflet_markers[mkey].coords[hash] == null) {
590      Drupal.getlocations_leaflet_markers[mkey].coords[hash] = 1;
591    }
592    else {
593      // we have a duplicate
594      // 10000 constrains the max, 0.0001 constrains the min distance
595      m1 = (Math.random() /10000) + 0.0001;
596      // randomise the operator
597      m2 = Math.random();
598      if (m2 > 0.5) {
599        lat = parseFloat(lat) + m1;
600      }
601      else {
602        lat = parseFloat(lat) - m1;
603      }
604      m1 = (Math.random() /10000) + 0.0001;
605      m2 = Math.random();
606      if (m2 > 0.5) {
607        lon = parseFloat(lon) + m1;
608      }
609      else {
610        lon = parseFloat(lon) - m1;
611      }
612    }
613
614    // make markers
615    var latLng = L.latLng(lat, lon);
616    var Marker = {};
617
618    if (icon || (vicon && gs.awesome)) {
619      if (vicon && gs.awesome) {
620        // icon only
621        if (marker_type == 'i') {
622          var px = parseInt(vicon.px);
623          var diopts = {
624            className: vicon.classname,
625            iconSize: [px, px],
626            html: vicon.html
627          };
628          var thisIcon = L.divIcon(diopts);
629        }
630        else {
631          var thisIcon = L.AwesomeMarkers.icon(vicon);
632        }
633      }
634      else if (icon) {
635        var thisIcon = L.icon({iconUrl: icon.iconUrl});
636        // override applicable marker defaults
637        if (icon.iconSize) {
638          thisIcon.options.iconSize = L.point(parseInt(icon.iconSize.x, 10), parseInt(icon.iconSize.y, 10));
639        }
640        if (icon.iconAnchor) {
641          thisIcon.options.iconAnchor = L.point(parseFloat(icon.iconAnchor.x, 10), parseFloat(icon.iconAnchor.y, 10));
642        }
643        if (icon.popupAnchor) {
644          thisIcon.options.popupAnchor = L.point(parseFloat(icon.popupAnchor.x, 10), parseFloat(icon.popupAnchor.y, 10));
645        }
646        if (icon.shadowUrl !== undefined) {
647          thisIcon.options.shadowUrl = icon.shadowUrl;
648          if (icon.shadowSize) {
649            thisIcon.options.shadowSize = L.point(parseInt(icon.shadowSize.x, 10), parseInt(icon.shadowSize.y, 10));
650          }
651          if (icon.shadowAnchor) {
652            thisIcon.options.shadowAnchor = L.point(parseInt(icon.shadowAnchor.x, 10), parseInt(icon.shadowAnchor.y, 10));
653          }
654        }
655      }
656      Marker = L.marker(latLng, {icon: thisIcon});
657    }
658    else {
659      // default leaflet marker
660      Marker = L.marker(latLng);
661    }
662
663    if (title) {
664      Marker.options.title = title;
665    }
666
667    // markeraction
668    if (markeraction && markeraction.type && markeraction.data) {
669      if (markeraction.type == 'popup') {
670        Marker.bindPopup(markeraction.data);
671      }
672      else if (markeraction.type == 'link') {
673        Marker.on('click', function() {
674          window.location = markeraction.data;
675        });
676      }
677    }
678    else {
679      Marker.options.clickable = false;
680    }
681
682    // bounce marker
683    if (gs.bouncemarker) {
684      Marker.options.bounceOnAdd = true;
685      Marker.options.bounceOnAddDuration = gs.bouncemarker_duration;
686      if (gs.bouncemarker_height) {
687        Marker.options.bounceOnAddHeight = gs.bouncemarker_height;
688      }
689    }
690
691    return Marker;
692  };
693
694  // redo map
695  Drupal.getlocations_leaflet.redoMap = function(key) {
696    if (Drupal.getlocations_leaflet_data[key].datanum > 1) {
697      var minmaxes = (Drupal.getlocations_leaflet_data[key].minmaxes ? Drupal.getlocations_leaflet_data[key].minmaxes : '');
698      if (minmaxes) {
699        var mmarr = minmaxes.split(',');
700        var sw = L.latLng(parseFloat(mmarr[2]), parseFloat(mmarr[3])),
701          ne = L.latLng(parseFloat(mmarr[0]), parseFloat(mmarr[1])),
702          bounds = L.latLngBounds(sw, ne).pad(0.1);
703        Drupal.getlocations_leaflet_map[key].invalidateSize().fitBounds(bounds, {reset: true});
704      }
705    }
706  };
707
708})(jQuery);

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.