Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function initMap() {
// Initalize Leaflet
map = L.map('map', {
zoomControl: false,
attributionControl: false,
maxZoom: 20,
keyboardZoomOffset: 0.05,
// Enables fractional zoom.
zoomSnap: 0,
// Prevents scroll wheel zoom when iframed.
scrollWheelZoom: (window.self === window.top),
// If iframed & touchscreen, disable dragging & tap to prevent Leaflet
// from hijacking the page scroll.
dragging: !(window.self !== window.top && L.Browser.touch),
tap: !(window.self !== window.top && L.Browser.touch),
});
// Provide alternate zoom in/zoom out button controls in embedded version
// since, when iframed, the scroll wheel zoom will no longer work.
if (store.getState().app.isEmbedded === true) {
const zoomControl = L.control.zoom();
zoomControl.addTo(map);
}
// Get map start position
getMapStartLocation()
.then((mapStartLocation) => {
// Create Leaflet map
map.setView(mapStartLocation.latlng, mapStartLocation.zoom);
onAdd: function (map) {
this._map = map;
// don't animate on browsers without hardware-accelerated transitions or old Android/Opera
if (typeof this._zoomAnimated == 'undefined') // Leaflet 0.7
this._zoomAnimated = L.DomUtil.TRANSITION && L.Browser.any3d && !L.Browser.mobileOpera && this._map.options.zoomAnimation;
if (L.version < '1.0') this._map.on(this.getEvents(), this);
if (!this._div) {
this._div = L.DomUtil.create('div', 'leaflet-image-layer');
if (this.options.pointerEvents) {
this._div.style['pointer-events'] = this.options.pointerEvents;
}
if (typeof this.options.zIndex !== 'undefined') {
this._div.style.zIndex = this.options.zIndex;
}
if (typeof this.options.opacity !== 'undefined') {
this._div.style.opacity = this.options.opacity;
}
}
this.getPane().appendChild(this._div);
var container = this._container
var size = b.getSize()
var m = L.Browser.retina ? 2 : 1
L.DomUtil.setPosition(container, b.min)
// set canvas size (also clearing it); use double size on retina
container.width = m * size.x
container.height = m * size.y
container.style.width = size.x + 'px'
container.style.height = size.y + 'px'
if (L.Browser.retina) {
this._ctx.scale(2, 2)
}
// translate so we use the same path coordinates after canvas element moves
this._ctx.translate(-b.min.x, -b.min.y)
// Tell paths to redraw themselves
this.fire('update')
}
})
mouseover: (e) => {
const layer = e.target;
// bring layer to front if not older browser
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
this._showTooltip(feature);
},
mouseout: () => {
export function initMap() {
// Initalize Leaflet
map = L.map('map', {
zoomControl: false,
attributionControl: false,
maxZoom: 20,
keyboardZoomOffset: 0.05,
// Enables fractional zoom.
zoomSnap: 0,
// Prevents scroll wheel zoom when iframed.
scrollWheelZoom: (window.self === window.top),
// If iframed & touchscreen, disable dragging & tap to prevent Leaflet
// from hijacking the page scroll.
dragging: !(window.self !== window.top && L.Browser.touch),
tap: !(window.self !== window.top && L.Browser.touch),
});
// Provide alternate zoom in/zoom out button controls in embedded version
// since, when iframed, the scroll wheel zoom will no longer work.
if (store.getState().app.isEmbedded === true) {
const zoomControl = L.control.zoom();
zoomControl.addTo(map);
}
// Get map start position
getMapStartLocation()
.then((mapStartLocation) => {
// Create Leaflet map
map.setView(mapStartLocation.latlng, mapStartLocation.zoom);
// Add leaflet-hash (forked version)
initialize: function(url, options) {
this.options.crs.wrapLat = this.options.crs.wrapLng = null
L.TileLayer.prototype.initialize.call(this, url, options)
this._adjustForRetina = this.options.detectRetina && L.Browser.retina
this._computeImageAndGridSize()
this.on('tileload', this._adjustNonSquareTile)
},
var L = require('leaflet');
var geometry = require('./geometry');
var ControlMarker = require('./marker');
var Endpoint = require('./endpoint');
var Selection = require('./selection');
var Rbush = global.Rbush || require('rbush');
var START = L.Browser.touch ? 'touchstart mousedown' : 'mousedown';
/**
* LineString select control
*
* @class L.Control.LineStringSelect
* @extends {L.Control}
*/
var Select = L.Control.extend( /** @lends Select.prototype */ {
statics: {
Selection: Selection,
Endpoint: Endpoint,
ControlMarker: ControlMarker
},
/**
setViewToBounds: function(bounds, immediate) {
if (bounds && bounds.isValid()) {
bounds = wrapLatLngBoundsToTarget(bounds, this.map.getCenter());
if (L.Browser.mobile || immediate) {
this.map.fitBounds(bounds, {maxZoom: 16});
} else {
this.map.flyToBounds(bounds, {maxZoom: 16});
}
}
},
_initImage: function () {
var _image = L.DomUtil.create('img', 'leaflet-image-layer');
this._div.appendChild(_image);
if (this._map.options.zoomAnimation && L.Browser.any3d) {
L.DomUtil.addClass(_image, 'leaflet-zoom-animated');
} else {
L.DomUtil.addClass(_image, 'leaflet-zoom-hide');
}
//TODO createImage util method to remove duplication
L.extend(_image, {
galleryimg: 'no',
onselectstart: L.Util.falseFn,
onmousemove: L.Util.falseFn,
onload: L.bind(this._onImageLoad, this),
onerror: L.bind(this._onImageError, this)
});
return _image;
_initContainer: function () {
var parentContainer = this.getPane();
var animated = this._map.options.zoomAnimation && L.Browser.any3d;
var className = 'themeLayer leaflet-layer leaflet-zoom-' + (animated ? 'animated' : 'hide');
this.container = L.DomUtil.create("div", className, parentContainer);
var originProp = L.DomUtil.testProp(['transformOrigin', 'WebkitTransformOrigin', 'msTransformOrigin']);
this.container.id = this.options.id;
this.container.style[originProp] = '50% 50%';
this.container.style.position = "absolute";
this.container.style.zIndex = 200;
},