1(function($){$.fn.osm=function(options){this.$canvas=$(this) 2this.$markers=this.$canvas.find('.marker') 3this.throttle=function(callback,delay){var last;var timer;return function(){var context=this;var now=+new Date();var args=arguments;if(last&&now<last+delay){clearTimeout(timer);timer=setTimeout(function(){last=now;callback.apply(context,args)},delay)}else{last=now;callback.apply(context,args)}}} 4this.debounce=function(callback,delay){var timer;return function(){var args=arguments;var context=this;clearTimeout(timer);timer=setTimeout(function(){callback.apply(context,args)},delay)}} 5this.initialize=function(){var defaults_settings={zoom:14,lat:'',lng:'',paddingBreakpoint:1200,padding:[40,40,40,40],markerCluster:!0,markers:{},mapboxToken:'',forceTileLayer:'',disableScrollZoom:!0,};this.settings=$.extend({},defaults_settings,options);if(typeof L.markerClusterGroup!=='function'){this.settings.markerCluster=!1} 6this.settings.padding={top:this.settings.padding[0],right:this.settings.padding[1],bottom:this.settings.padding[2],left:this.settings.padding[3],} 7this.initializeMap();return this} 8this.initializeMap=function(){var self=this,map,promises=[];map=L.map(self[0]) 9if(this.settings.lat!=''&&this.settings.lng!=''){var latLng=this.newLatLng(parseFloat(this.settings.lat),parseFloat(this.settings.lng));map.setView(latLng,parseInt(this.settings.zoom))} 10if(this.settings.disableScrollZoom==!0){map.scrollWheelZoom.disable()} 11var tileLayer='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';if(this.settings.mapboxToken!==''){var tileLayer='https://api.mapbox.com/styles/v1/mapbox/streets-v9/tiles/256/{z}/{x}/{y}@2x?access_token='+this.settings.mapboxToken} 12if(this.settings.forceTileLayer!==''){var tileLayer=this.settings.forceTileLayer} 13var attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>';L.tileLayer(tileLayer,{attribution:attribution,}).addTo(map);map.markers=[];map.bounds=[];if(self.settings.markerCluster){map.clusterGroup=L.markerClusterGroup()} 14for(var i=0;i<self.settings.markers.length;i++){promises=self.addMarker(map,self.settings.markers[i],promises)} 15if(self.settings.markerCluster){map.addLayer(map.clusterGroup)} 16self.addMapEvents(map);self.map=map;if(this.settings.lat==''||this.settings.lng==''){Promise.all(promises).then(function(data){self.center();setTimeout(function(){if(typeof map.markers[0]!='undefined'&&map.markers.length==1){map.markers[0].openPopup()}},1000)})}} 17this.newLatLng=function(lat,lng){return L.latLng(parseFloat(lat),parseFloat(lng))},this.getWindowSize=function(){var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;return{width:x,height:y}},this.addMarker=function(map,marker,promises){var self=this,bounds;var marker_defaults_settings={file:'',lat:'',lng:'',html:'',hoverSelector:'',iconUrl:'',iconActiveUrl:'',shadowUrl:'',shadowActiveUrl:'',iconSize:[32,37],tooltip:'',href:'',hrefTarget:'',};marker=$.extend({},marker_defaults_settings,marker);var advancedMarkersSettings=['iconSize','iconActiveSize','shadowSize','shadowActiveSize','iconAnchor','iconActiveAnchor','shadowAnchor','shadowActiveAnchor','popupAnchor','popupActiveAnchor'];for(var i=advancedMarkersSettings.length-1;i>=0;i--){if(typeof marker[advancedMarkersSettings[i]]==='string'){marker[advancedMarkersSettings[i]]=marker[advancedMarkersSettings[i]].split(',') 18for(var o=marker[advancedMarkersSettings[i]].length-1;o>=0;o--){marker[advancedMarkersSettings[i]][o]=parseInt(marker[advancedMarkersSettings[i]][o])}}} 19if(marker.file!==''){var extension=marker.file.split('.').pop() 20if(extension=='kmz'){var kmz=marker.file;promises.push(fetch(kmz).then(function(response){if(response.status===200||response.status===0){return Promise.resolve(response.blob())}else{return Promise.reject(new Error(response.statusText))}}).then(JSZip.loadAsync).then(function(zip){var kml='';var zipPromises=[];var imgFormats=['jpg','jpeg','png','gif','svg'];zip.forEach(function(relativePath,file){var extension=relativePath.split('.').pop();
20if(extension=='kml'){zipPromises.push(zip.file(relativePath).async('string').then(function(kml){var imgPromises=[];var editedKml=kml;zip.forEach(function(relativePath,file){var extension=relativePath.split('.').pop();var mimetype='';if(imgFormats.indexOf(extension)){if(extension=='jpg'){mimetype='image/jpeg'}else if(extension=='svg'){mimetype='image/svg+xml'}else{mimetype='image/'+extension} 21imgPromises.push(zip.file(relativePath).async('base64').then(function(content){editedKml=editedKml.replace(relativePath,'data:'+mimetype+';base64,'+content)}))}});return Promise.all(imgPromises).then(function(data){return editedKml})}))}});return Promise.all(zipPromises).then(function(data){return data[0]})}).then(function success(kml){var parser=new DOMParser();kml=parser.parseFromString(kml,'text/xml');for(var i=kml.getElementsByTagName('description').length-1;i>=0;i--){kml.getElementsByTagName('description')[i].textContent=self.linkify(kml.getElementsByTagName('description')[i].textContent)} 22var track=new L.KML(kml) 23if(marker.html!==''){$.each(track._layers,function(index,val){val.bindPopup(marker.html)})} 24if(self.settings.markerCluster){map.clusterGroup.addLayer(track)}else{track.addTo(map)} 25bounds=track.getBounds() 26map.bounds.push(bounds.getNorthEast());
26map.bounds.push(bounds.getSouthWest())},function error(e){console.log('Une erreur est survenue sur l\'affichage d\'un kmz')}))}else if(extension=='kml'){promises.push(fetch(marker.file).then(function(response){return response.text()}).then(function(kml){var parser=new DOMParser();kml=parser.parseFromString(kml,'text/xml');for(var i=kml.getElementsByTagName('description').length-1;i>=0;i--){kml.getElementsByTagName('description')[i].textContent=self.linkify(kml.getElementsByTagName('description')[i].textContent)} 27var track=new L.KML(kml) 28if(marker.html!==''){$.each(track._layers,function(index,val){val.bindPopup(marker.html)})} 29if(self.settings.markerCluster){map.clusterGroup.addLayer(track)}else{track.addTo(map)} 30bounds=track.getBounds() 31map.bounds.push(bounds.getNorthEast());map.bounds.push(bounds.getSouthWest())}))}else if(extension=='geojson'){promises.push(fetch(marker.file).then(function(response){return response.json()}).then(function(data){var track=new L.geoJSON(data,{onEachFeature:function(feature,layer){if(feature.properties&&(feature.properties.name||feature.properties.nom||feature.properties.popupContent)){var content='<div class="infowindow">';content+='<div class="infowindow-body">';if(feature.properties.name){content+='<h3 class="infowindow-title">'+feature.properties.name+'</h3>'} 32if(feature.properties.nom){content+='<h3 class="infowindow-title">'+feature.properties.nom+'</h3>'} 33if(feature.properties.popupContent){content+='<div class="infowindow-text">'+feature.properties.popupContent+'</div>'} 34content+='</div>';content+='</div>';if(content!==''){layer.bindPopup(content)}}}}) 35if(self.settings.markerCluster){map.clusterGroup.addLayer(track)}else{track.addTo(map)} 36bounds=track.getBounds() 37map.bounds.push(bounds.getNorthEast());
37map.bounds.push(bounds.getSouthWest())}))}} 38if(marker.lat!==''&&marker.lng!==''){var latLng=self.newLatLng(parseFloat(marker.lat),parseFloat(marker.lng)),new_marker;if(marker.iconUrl!==''){var iconSettings={iconUrl:marker.iconUrl,iconSize:marker.iconSize,iconAnchor:(marker.iconAnchor!=undefined&&marker.iconAnchor!=='')?marker.iconAnchor:[marker.iconSize[0]/2,marker.iconSize[1]],popupAnchor:(marker.popupAnchor!=undefined&&marker.popupAnchor!=='')?marker.popupAnchor:[0,(marker.iconSize[1]*-1)]};if(marker.shadowUrl!=undefined&&marker.shadowUrl!==''){iconSettings.shadowUrl=marker.shadowUrl} 39if(marker.shadowSize!=undefined&&marker.shadowSize!==''){iconSettings.shadowSize=marker.shadowSize} 40if(marker.shadowAnchor!=undefined&&marker.shadowAnchor!==''){iconSettings.shadowAnchor=marker.shadowAnchor} 41var icon=L.icon(iconSettings);new_marker=L.marker(latLng,{icon:icon})}else{new_marker=L.marker(latLng)} 42if(marker.html!==''){new_marker.bindPopup(marker.html,{maxWidth:600})} 43if(marker.tooltip!==''){new_marker.on('mouseover',function(e){self.showTooltip(new_marker,marker.tooltip)})} 44if(marker.href!==''){new_marker.on('click',function(){var target='_self';if(marker.hrefTarget!=''){target=marker.hrefTarget} 45window.open(marker.href,target)})} 46if(marker.hoverSelector!==''&&marker.iconActiveUrl!==''){var icon=new_marker.getIcon();if($(marker.hoverSelector).length){$(marker.hoverSelector).on('mouseenter',function(){var iconSettings={iconUrl:marker.iconActiveUrl,};if(marker.iconActiveSize!=undefined&&marker.iconActiveSize!==''){iconSettings.iconSize=marker.iconActiveSize;if(marker.iconActiveAnchor!=undefined&&marker.iconActiveAnchor!==''){iconSettings.iconAnchor=marker.iconActiveAnchor}else{iconSettings.iconAnchor=[marker.iconActiveSize[0]/2,marker.iconActiveSize[1]]} 47if(marker.popupActiveAnchor!=undefined&&marker.popupActiveAnchor!==''){iconSettings.popupAnchor=marker.popupActiveAnchor}else{iconSettings.popupAnchor=[0,(marker.iconActiveSize[1]*-1)]}}else{iconSettings.iconSize=marker.iconSize;if(marker.iconActiveAnchor!=undefined&&marker.iconActiveAnchor!==''){iconSettings.iconAnchor=marker.iconActiveAnchor}else{iconSettings.iconAnchor=[marker.iconSize[0]/2,marker.iconSize[1]]} 48if(marker.popupActiveAnchor!=undefined&&marker.popupActiveAnchor!==''){iconSettings.popupAnchor=marker.popupActiveAnchor}else{iconSettings.popupAnchor=[0,(marker.iconSize[1]*-1)]}} 49if(marker.shadowActiveUrl!=undefined&&marker.shadowActiveUrl!==''){iconSettings.shadowActiveUrl=marker.shadowActiveUrl} 50if(marker.shadowActiveSize!=undefined&&marker.shadowActiveSize!==''){iconSettings.shadowActiveSize=marker.shadowActiveSize} 51if(marker.shadowActiveAnchor!=undefined&&marker.shadowActiveAnchor!==''){iconSettings.shadowActiveAnchor=marker.shadowActiveAnchor} 52var activeIcon=L.icon(iconSettings);new_marker.setIcon(activeIcon) 53new_marker._icon.classList.add('active')}).on('mouseleave',function(){new_marker._icon.classList.remove('active') 54new_marker.setIcon(icon)})}} 55map.bounds.push([marker.lat,marker.lng]);map.markers.push(new_marker);if(self.settings.markerCluster){map.clusterGroup.addLayer(new_marker)}else{new_marker.addTo(map)}} 56if(typeof marker.polyline!='undefined'&&marker.polyline!==''){var polyline=L.polyline(jQuery.parseJSON(marker.polyline)).addTo(map);if(marker.html!==''){polyline.bindPopup(marker.html,{maxWidth:600})} 57bounds=polyline.getBounds() 58map.bounds.push(bounds.getNorthEast());
58map.bounds.push(bounds.getSouthWest())} 59if(typeof marker.polygon!='undefined'&&marker.polygon!==''){var polygon=L.polygon(jQuery.parseJSON(marker.polygon),{color:'red'}).addTo(map);if(marker.html!==''){polygon.bindPopup(marker.html,{maxWidth:600})} 60bounds=polygon.getBounds() 61map.bounds.push(bounds.getNorthEast());map.bounds.push(bounds.getSouthWest())} 62return promises} 63this.showTooltip=function(marker,content){marker.unbindTooltip();if(!marker.isPopupOpen()){marker.bindTooltip(content,{direction:'top',}).openTooltip()}} 64this.addMapEvents=function(map){var self=this;map.on('popupopen',function(e){var px=map.project(e.popup._latlng);px.y-=e.popup._container.clientHeight/2 65if(self.getWindowSize().width>parseInt(self.settings.paddingBreakpoint)){px.x=px.x-(self.settings.padding.left/2)+(self.settings.padding.right/2) 66px.y=px.y-(self.settings.padding.top/2)+(self.settings.padding.bottom/2)} 67map.panTo(map.unproject(px),{animate:!0})});$(window).on('resize',self.debounce(function(e){if(self.settings.lat!=''&&self.settings.lng!=''){map.panTo(new L.LatLng(parseFloat(self.settings.lat),parseFloat(self.settings.lng)))}else{self.center()}},150))} 68this.center=function(){var self=this;if(self.map.bounds.length){bounds=new L.LatLngBounds(self.map.bounds);if(self.getWindowSize().width>parseInt(self.settings.paddingBreakpoint)){self.map.fitBounds(bounds,{paddingTopLeft:[self.settings.padding.left,self.settings.padding.top],paddingBottomRight:[self.settings.padding.right,self.settings.padding.bottom],maxZoom:this.settings.zoom,})}else{self.map.fitBounds(bounds,{maxZoom:this.settings.zoom})}}} 69this.refresh=function(){var self=this;self.map.invalidateSize(!0)} 70this.linkify=function(inputText){var replacedText,replacePattern1,replacePattern2,replacePattern3;replacePattern1=/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;replacedText=inputText.replace(replacePattern1,'<a href="$1" target="_blank">$1</a>');replacePattern2=/(^|[^\/])(www\.[\S]+(\b|$))/gim;replacedText=replacedText.replace(replacePattern2,'$1<a href="http://$2" target="_blank">$2</a>');replacePattern3=/(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;replacedText=replacedText.replace(replacePattern3,'<a href="mailto:$1">$1</a>');return replacedText} 71return this.initialize()}}(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.