Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_redraw: function (id) {
var layer = this._layers[id];
var geojson = layer.feature;
// if this looks like a marker
if (layer && layer.setIcon && this.options.pointToLayer) {
// update custom symbology, if necessary
if (this.options.pointToLayer) {
var getIcon = this.options.pointToLayer(geojson, latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]));
var updatedIcon = getIcon.options.icon;
layer.setIcon(updatedIcon);
}
}
// looks like a vector marker (circleMarker)
if (layer && layer.setStyle && this.options.pointToLayer) {
var getStyle = this.options.pointToLayer(geojson, latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]));
var updatedStyle = getStyle.options;
this.setFeatureStyle(geojson.id, updatedStyle);
}
// looks like a path (polygon/polyline)
if (layer && layer.setStyle && this.options.style) {
this.resetStyle(geojson.id);
}
export function extentToBounds (extent) {
// "NaN" coordinates from ArcGIS Server indicate a null geometry
if (extent.xmin !== 'NaN' && extent.ymin !== 'NaN' && extent.xmax !== 'NaN' && extent.ymax !== 'NaN') {
var sw = latLng(extent.ymin, extent.xmin);
var ne = latLng(extent.ymax, extent.xmax);
return latLngBounds(sw, ne);
} else {
return null;
}
}
12,
46.879966, -121.726909,
[ this.LAYER_OSM, this.LAYER_OCM ],
this.LAYER_OSM.id
);
// Leaflet values
leaflet: {
layers: L.Layer[],
zoom: number,
center: L.LatLng
} = {
layers: [],
zoom: 0,
center: L.latLng([ 0, 0 ])
};
constructor() {
this.onApply();
setTimeout(() => {
this.showDemo = true;
}, 1000);
}
onApply() {
// Get the active base layer
let baseLayer = this.model.baseLayers.find((l) => { return l.id === this.model.baseLayer; });
// Get all the active control layers
it("Should be able to add new points to the path", () => {
const coord = L.latLng(42, 42);
antPath.addLatLng(coord);
expect(antPath.getLatLngs()).toEqual([...samplePath, coord]);
});
let newLine = [wrappedLatLngs[0]];
newLines.push(newLine);
for (let i = 1; i < wrappedLatLngs.length; i++) {
let latLng = wrappedLatLngs[i];
let prevLatLng = wrappedLatLngs[i - 1];
if (Math.abs(latLng.lng - prevLatLng.lng) <= 180) {
newLine.push(latLng);
} else {
let positiveLng = L.Util.wrapNum(latLng.lng, [0, 360]);
let positivePrevLng = L.Util.wrapNum(prevLatLng.lng, [0, 360]);
let splitLng = 180 - 0.000001 * Math.sign(latLng.lng);
let splitPrevLng = 180 - 0.000001 * Math.sign(prevLatLng.lng);
let splitLat = getSegmentLatForLng(L.latLng(prevLatLng.lat, positivePrevLng), L.latLng(latLng.lat, positiveLng), splitLng);
let splitPrevLat = getSegmentLatForLng(L.latLng(prevLatLng.lat, positivePrevLng), L.latLng(latLng.lat, positiveLng), splitPrevLng);
newLine.push(L.latLng(splitPrevLat, splitPrevLng).wrap());
newLine = [L.latLng(splitLat, splitLng).wrap(), latLng];
newLines.push(newLine);
}
}
return newLines;
}
constructor() {
this.canvasRender = !!document.createElement('canvas').getContext && USE_CANVAS_MAP;
this.darkBasemap = false;
const mapOptions = {
zoomControl: false,
minZoom: 2,
preferCanvas: this.canvasRender
};
this.map = L.map('js-map', mapOptions);
new L.Control.Zoom({ position: 'topleft' }).addTo(this.map);
L.control.scale({ position: 'bottomleft', imperial: false }).addTo(this.map);
const worldBounds = L.latLngBounds(L.latLng(-89, -180), L.latLng(89, 180));
this.map.setMaxBounds(worldBounds);
this.map.on('drag', () => {
this.map.panInsideBounds(worldBounds, { animate: false });
});
this.map.on('layeradd', () => this._updateAttribution());
this.map.on('dragend zoomend', () =>
this.callbacks.onMoveEnd(this.map.getCenter(), this.map.getZoom())
);
this.map.on('zoomend', () => {
this._recalculatePointVolumeShadowRadius();
});
this._setMapViewDebounced = debounce(this._setMapViewDebounced, 500);
Object.keys(MAP_PANES).forEach(paneKey => {
private centerMap = () => {
const mapStore = this.props.mapStore;
const map = this.getMap();
if (map) {
try {
const mapCoordinates = map.getCenter();
if (!L.latLng(mapStore!.coordinates!).equals(L.latLng(mapCoordinates))) {
map.setView(mapStore!.coordinates!, map.getZoom());
}
} catch {
map.setView(mapStore!.coordinates!, mapStore!.zoom);
}
}
};
fitBounds(): void {
const points = this.props.points;
const lngs = map(points, this.props.longitudeExtractor);
const lats = map(points, this.props.latitudeExtractor);
const ne = { lng: max(lngs), lat: max(lats) };
const sw = { lng: min(lngs), lat: min(lats) };
if (shouldIgnoreLocation(ne) || shouldIgnoreLocation(sw)) {
return;
}
this.context.map.fitBounds(L.latLngBounds(L.latLng(sw), L.latLng(ne)));
}
handleViewportChange() {
const latLngBounds = this.mapApi.getBounds();
const northEast = latLngBounds.getNorthEast();
const southWest = latLngBounds.getSouthWest();
const newNorthEast = L.latLng(northEast.lat + 1, northEast.lng + 2);
const newSouthWest = L.latLng(southWest.lat - 1, southWest.lng - 2);
const expandedBounds = L.latLngBounds(newSouthWest, newNorthEast);
new SiteIterator()
.withPredicate(SitePredicates.HAS_NO_MARKER)
.withPredicate(SitePredicates.buildInViewPredicate(expandedBounds))
.iterate((supercharger) => this.markerFactory.createMarker(supercharger));
EventBus.dispatch("map-viewport-change-event", latLngBounds);
const mapCenter = this.getCenter();
userConfig.setLatLngZoom(mapCenter.lat, mapCenter.lng, this.mapApi.getZoom());
};
doApply() {
this.center = latLng(this.lat, this.lng);
this.zoom = this.formZoom;
}
}