How to use the leaflet.LatLng function in leaflet

To help you get started, we’ve selected a few leaflet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github osmlab / maproulette3 / src / services / MapBounds / MapBounds.js View on Github external
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)
    }
  }
github graphhopper / graphhopper / web / src / main / resources / assets / js / main-template.js View on Github external
}
                }
            }
        }
        // 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");
        });
    });
}
github Hub-of-all-Things / Rumpel / src / app / locations / map / map.component.ts View on Github external
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>
github teamapps-org / teamapps / teamapps-client / ts / modules / UiMap.ts View on Github external
private createLeafletLatLng(location: UiMapLocationConfig) {
		return new L.LatLng(location.latitude, location.longitude);
	}
github anthill / 6element / core / clients / Citizen / src / views / mainView.jsx View on Github external
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
            });
        }
github 52North / helgoland / src / app / toolbox / components / display / d-three-graph / d-three-graph.component.ts View on Github external
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
        };
    }
github rendrom / rosreestr2coord / gui / client / app / components / r2c.js View on Github external
let getLatLngFromMarker = function (marker) {
    return new L.LatLng(marker.getLatLng().lat, marker.getLatLng().lng);
};
github teamapps-org / teamapps / teamapps-client / ts / modules / UiMap.ts View on Github external
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;
	};
github TNRIS / flood / src / components / Map.jsx View on Github external
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()
    }
  }
github mapcontrib / mapcontrib / public / js / view / contribute / add / formColumn.js View on Github external
_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 });
  },