1 2function appendLayer( map ) 3{ 4 let layer = new L.layerGroup( { interactive: false } ); 5 layer.addTo( map ); 6 7 return layer; 8} 9 10function appendMarker( layer, location, iconUrl, aAnchor ) 11{ 12 let icon = new L.icon( { iconUrl: iconUrl, iconAnchor: aAnchor } ); 13 let marker = new L.marker( location, { icon: icon, draggable: true } ); 14 marker.addTo( layer ); 15 16 return marker; 17} 18 19function appendMarkerSvg( layer, lat, long, iconSvg, aAnchor ) 20{ 21 let icon = new L.divIcon( { html: iconSvg, iconAnchor: aAnchor, className: null } ); 22 let marker = new L.marker( L.latLng( lat, long ), { icon: icon, interactive: false } ); 23 marker.addTo( layer ); 24 25 return marker; 26} 27 28function appendPolyline( layer, aLocation, color, thickness, dashed ) 29{ 30 let line = new L.polyline( aLocation, { color: color, weight: thickness, dashArray: dashed ? "3 8" : null, interactive: false } ); 31 line.addTo( layer ); 32 33 return line; 34} 35 36function clearLayer( layer ) 37{ 38 layer.clearLayers(); 39} 40 41function cloneViewRect( bounds ) 42{ 43 return new L.latLngBounds( bounds ); 44} 45 46function enablePan( bEnable ) 47{ 48 if( bEnable ) 49 map.dragging.enable(); 50 else 51 map.dragging.disable(); 52} 53 54function fitBounds( map, viewRect, bPadding = false ) 55{ 56 map.fitBounds( viewRect, { animate: false, padding: bPadding ? [25, 25] : [0, 0] } ); 57} 58 59function fitBounds2( map, aLocation, bPadding = false ) 60{ 61 map.fitBounds( new L.latLngBounds( aLocation ), { animate: false, padding: bPadding ? [25, 25] : [0, 0] } ); 62} 63 64function fitLocation( map, loc ) 65{ 66 let bounds = map.getBounds(); 67 if( !bounds.contains( loc ) )
68 map.setView( loc, map.getZoom(), { animate: false } ); 69} 70 71function getBounds( map ) 72{ 73 return map.getBounds(); 74} 75 76function getBoundsCenter( bounds ) 77{ 78 return bounds.getCenter(); 79} 80 81function getCenter( map ) 82{ 83 return map.getCenter(); 84} 85 86function getDragEndPoint( e ) 87{ 88 return map.latLngToContainerPoint( e.target.getLatLng() ); 89} 90 91function getLocationAsString( loc ) 92{ 93 return loc.lat + ", " + loc.lng; 94} 95 96function getLocationLat( loc ) 97{ 98 return loc.lat; 99} 100 101function getLocationLong( loc ) 102{ 103 return loc.lng; 104} 105 106function getLocationFromMouseEvent( e ) 107{ 108 return map.mouseEventToLatLng( e ); 109} 110 111function getLocationFromMapMouseEvent( e ) 112{ 113 return e.latlng; 114} 115 116function getMarkerLocation( marker ) 117{ 118 return marker.getLatLng(); 119} 120 121function getZoom( map ) 122{ 123 return map.getZoom(); 124} 125 126function getViewAsJson( map ) 127{ 128 let center = map.getCenter(); 129 return JSON.stringify( { lat: center.lat, long: center.lng, zoom: map.getZoom() } ); 130} 131 132function getViewPoint( lat, long ) 133{ 134 return new L.latLng( lat, long ); 135} 136 137function getViewRect( lat0, long0, lat1, long1 ) 138{ 139 return new L.latLngBounds( [L.latLng( lat0, long0 ), L.latLng( lat1, long1 )] ); 140} 141 142function getViewRectFromString( str ) 143{ 144 let na = str.split( "," ); 145 return new L.latLngBounds( L.latLng( na[0], na[1] ), L.latLng( na[2], na[3] ) ); 146} 147 148function reCenter( map ) 149{ 150} 151 152function removeFromLayer( layer, o ) 153{ 154 o.removeFrom( layer ); 155} 156 157function setMarkerLocation( marker, loc ) 158{ 159 marker.setLatLng( loc ); 160} 161 162function setView( map, center, zoom ) 163{
164 map.setView( center, zoom, { animate: false } ); 165} 166 167function setView2( map, lat, long, zoom ) 168{ 169 map.setView( new L.latLng( lat, long ), zoom, { animate: false } ); 170} 171 172function setView3( map, lat, long, offsetX, offsetY, zoom ) 173{ 174 map.setZoom( zoom, { animate: false } ); 175 let pt = map.latLngToContainerPoint( new L.latLng( lat, long ) ); 176 pt.x -= offsetX; 177 pt.y -= offsetY; 178 let ll = map.containerPointToLatLng( pt ); 179 map.setView( ll, zoom, { animate: false } ); 180} 181 182function setZoom( map, zoom ) 183{ 184 map.setZoom( zoom, { animate: false } ); 185} 186 187function createMap( divMap, viewRect, urlTemplate, layerOptions, zoomPosition = null ) 188{ 189 let map = new L.map( divMap, { zoomControl: zoomPosition == null, zoomAnimation: true, zoomSnap: 0.5, zoomDelta: 0.5, wheelPxPerZoomLevel: 200 } ); 190 if( zoomPosition != null ) 191 new L.control.zoom( { position: zoomPosition } ).addTo( map ); 192 193 new L.tileLayer( urlTemplate, layerOptions ).addTo( map ); 194 if( viewRect ) map.fitBounds( viewRect, { animate: false } ); 195 196 return map; 197} 198 199function addHandlers( map, fn0, fn1, fn2, fn3, fn4 ) 200{ 201 map.on( "movestart", fn0 ); 202 map.on( "move", fn1 ); 203 map.on( "moveend", fn2 ); 204 map.on( "zoomstart", fn3 ); 205 map.on( "zoomend", fn4 ); 206} 207 208function addHandler( o, name, fn ) 209{ 210 o.on( name, fn ); 211}
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.