Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const toLatLngBounds = function(arrayBounds) {
if (_isEmpty(arrayBounds)) {
return null
}
else if (_isArray(arrayBounds) && arrayBounds.length === 4) {
const southWest = new LatLng(arrayBounds[1], arrayBounds[0])
const northEast = new LatLng(arrayBounds[3], arrayBounds[2])
return new LatLngBounds(southWest, northEast)
}
else if (_isFunction(arrayBounds.toBBoxString)) {
// they gave us a LatLngBounds. Just return it.
return arrayBounds
}
else if (_isString(arrayBounds)) {
const bounds = _split(arrayBounds, ',')
if (bounds && bounds.length === 4) {
return toLatLngBounds(bounds)
}
else {
throw new Error("Invalid bounds given: " + arrayBounds)
}
}
}
}
}
}
// already select best path
firstHeader.click();
mapLayer.adjustMapSize();
// TODO change bounding box on click
var firstPath = json.paths[0];
if (firstPath.bbox && doZoom) {
var minLon = firstPath.bbox[0];
var minLat = firstPath.bbox[1];
var maxLon = firstPath.bbox[2];
var maxLat = firstPath.bbox[3];
var tmpB = new L.LatLngBounds(new L.LatLng(minLat, minLon), new L.LatLng(maxLat, maxLon));
mapLayer.fitMapToBounds(tmpB);
}
$('.defaulting').each(function (index, element) {
$(element).css("color", "black");
});
});
}
drawMarkers(locations: SheMapItem[]): void {
this.map.removeLayer(this.markers);
this.markers = leaflet.markerClusterGroup();
this.resetBoundingBox();
// const pointlist = [];
for (const loc of locations || []) {
this.adjustBoundingBox(loc.latitude, loc.longitude);
const pos = new leaflet.LatLng(loc.latitude, loc.longitude);
const marker = leaflet.marker(pos, { icon: this[loc.source + 'Pin'] });
// marker.timestamp = loc.data.dateCreated;
const date = moment(Number(loc.timestamp * 1000));
let popupContent: string;
if (loc.content) {
popupContent = `
<h4 class="rum-map-popup-header">${loc.content.title}</h4>
<div class="rum-map-popup-content">${loc.content.body}</div>
<div class="rum-map-popup-footer">Posted on ${date.format('YYYY-MM-DD hh:mma')}</div>`;
} else {
popupContent = `
<h4 class="rum-map-popup-header">From your ${loc.source} device</h4>
<div class="rum-map-popup-content"></div>
private createLeafletLatLng(location: UiMapLocationConfig) {
return new L.LatLng(location.latitude, location.longitude);
}
color: isCenter?'black':object.color,
fill: true,
fillColor: object.color,
fillOpacity: isCenter?1:0.7,
radius: isCenter?10:5,
clickable: true,
weight: '5px'
};
if(isSelected){
markerSelected = new L.Marker(new L.LatLng(object.geometry.coordinates.lat, object.geometry.coordinates.lon), {icon: pingIcon});
marker.on("click", self.clickMarker);
map.setView([object.geometry.coordinates.lat, object.geometry.coordinates.lon], 16);
}
else if (isCenter){
var marker = new L.CircleMarker(new L.LatLng(object.geometry.coordinates.lat, object.geometry.coordinates.lon), options);
marker.on("click", self.clickMarker);
marker.addTo(map);
markers.push({
id: marker._leaflet_id,
marker: marker
});
}
else{
var marker = new L.Circle(new L.LatLng(object.geometry.coordinates.lat, object.geometry.coordinates.lon), 10, options);
marker.addTo(map);
marker.on("click", self.clickMarker);
markers.push({
id: marker._leaflet_id,
marker: marker
});
}
private createDataEntry(entry: LocatedTimeValueEntry, previous: DataEntry, index: number): DataEntry {
const s = new L.LatLng(entry.geometry.coordinates[1], entry.geometry.coordinates[0]);
let dist: number;
if (previous) {
const e = new L.LatLng(previous.geometry.coordinates[1], previous.geometry.coordinates[0]);
const newdist = s.distanceTo(e);
dist = previous.dist + Math.round(newdist / 1000 * 100000) / 100000;
} else {
dist = 0;
}
return {
tick: index,
dist: Math.round(dist * 10) / 10,
timestamp: entry.timestamp,
value: entry.value,
x: entry.geometry.coordinates[0],
y: entry.geometry.coordinates[1],
latlng: s,
geometry: entry.geometry
};
}
let getLatLngFromMarker = function (marker) {
return new L.LatLng(marker.getLatLng().lat, marker.getLatLng().lng);
};
iconWidth = iconElement.size;
} else if (isUiImageElement(iconElement)) {
iconWidth = iconElement.width;
} else if (isUiIconElement(iconElement)) {
iconWidth = iconElement.size;
}
}
}
let divIcon = L.divIcon({
html: renderer.render(markerConfig.values),
className: "custom-div-icon",
iconAnchor: [markerConfig.offsetPixelsX, markerConfig.offsetPixelsY],
popupAnchor: [(iconWidth / 2) - 6, -5]
} as L.DivIconOptions);
let marker = L.marker(new L.LatLng(markerConfig.location.latitude, markerConfig.location.longitude), {
title: markerConfig.asString,
icon: divIcon
});
marker.bindPopup(markerConfig.asString);
marker.on("click", event1 => this.onMarkerClicked.fire({
markerId: markerConfig.id
}));
this.markersByClientId[markerConfig.id] = marker;
return marker;
};
const nextActiveBaseLayer = this.props.baseLayers.active
if (activeBaseLayer !== nextActiveBaseLayer) {
basemaps[nextActiveBaseLayer].addTo(this.map)
this.map.eachLayer((layer) => {
if (layer.options.layerId === activeBaseLayer) {
this.map.removeLayer(layer)
}
})
}
if (this.props.map.mapCenterLat && this.props.map.mapCenterLng && this.props.map.zoomLevel) {
const latlngPoint = new L.LatLng(this.props.map.mapCenterLat, this.props.map.mapCenterLng)
this.map.setView(latlngPoint, this.props.map.zoomLevel)
this.props.clearCenterAndZoom()
}
}
_buildNewMarker(latLng) {
const pos = new L.LatLng(latLng.lat, latLng.lng);
const icon = MapUi.buildLayerIcon(
new LayerModel({
markerShape: this._config.newPoiMarkerShape,
markerIconType: CONST.map.markerIconType.library,
markerIcon: this._config.newPoiMarkerIcon,
markerColor: this._config.newPoiMarkerColor
})
);
return L.marker(pos, { icon });
},