leaflet

Leaflet with next.js?

假如想象 提交于 2021-02-20 06:09:58
问题 I am getting a ReferenceError: window is not defined when using next.js with leaflet.js . Wondering if there's a simple solution to this problem - is using next.js overcomplicating my workflow? for those curious with the exact code, import React, { createRef, Component } from "react"; import L from "leaflet"; import { Map, TileLayer, Marker, Popup, DivOverlay } from "react-leaflet"; import axios from "axios"; import Header from "./Header"; export default class PDXMap extends Component { state

How to pass and get additional data/values from react-leaflet Marker?

青春壹個敷衍的年華 提交于 2021-02-20 04:19:26
问题 I am adding a group of markers to a map using react-leaflet. At present I can display the markers on the map with a custom icon. How do add a record of data to each marker. I assume I have to somehow create a custom marker class? Does anyone now how I could add a data record to each marker or at least an index. This is the code so far: import React, { Component } from 'react'; import { Map, TileLayer, Marker } from 'react-leaflet'; import {Navbar, Nav, NavDropdown} from 'react-bootstrap';

How to simultaneously add new markers and remove old markers associated with polygon clicks in leaflet

旧巷老猫 提交于 2021-02-19 01:32:05
问题 I have a map with Geojson polygons where each polygon is identified by a unique ID. I have a separate Geojson of point markers where each point is associated with a polygon with the same polygon ID, as well as a unique identifier for each individual point. The initial map display is of only polygons. Each polygon click will display the points that are associated with the clicked polygon. When a new polygon is clicked, I want to plot the points associated with the new polygon while

marker icon isn't showing in Leaflet

霸气de小男生 提交于 2021-02-17 00:00:18
问题 I 've put together a very simple React / Leaflet demo but the marker icon is not showing at all. Full running code is here. Here's what I have in my componentDidMount method: componentDidMount() { this.map = L.map("map-id", { center: [37.98, 23.72], zoom: 12, zoomControl: true }); const mapboxAccessToken = "pk.eyJ1IjoibXBlcmRpa2VhcyIsImEiOiJjazZpMjZjMW4wOXJzM2ttc2hrcTJrNG9nIn0.naHhlYnc4czWUjX0-icY7Q"; L.tileLayer( "https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=

How to plot MULTILINESTRING in leaflet addPolylines?

梦想的初衷 提交于 2021-02-11 15:53:31
问题 The leaflet documentation says: Line and polygon data can come from a variety of sources: [...] MULTIPOLYGON, POLYGON, MULTILINESTRING, and LINESTRING objects (from the sf package) Yet how do I make use of such objects in leaflet? Here is a MULTILINESTRING example: # attach packages--------------------------------------------------------------- library(dplyr) library(sf) library(leaflet) # set up data ------------------------------------------------------------------ set.seed(5) data <-

Change color of leaflet map

眉间皱痕 提交于 2021-02-11 15:49:05
问题 I want to change color of the map in leafletjs but I just can't figure out which class it is. I found .leaflet-container { background-color:rgba(255,0,0,0.0); } however it only changes the color outside the map (you see it when map is zoomed out completely) but which classes are responsible for countries color and water? 回答1: Yes, you can change the color of map tiles. With Mapbox Studio you can design interactive maps. Also you can set any/single/multiple language for all the countries.

Change color of leaflet map

痞子三分冷 提交于 2021-02-11 15:48:25
问题 I want to change color of the map in leafletjs but I just can't figure out which class it is. I found .leaflet-container { background-color:rgba(255,0,0,0.0); } however it only changes the color outside the map (you see it when map is zoomed out completely) but which classes are responsible for countries color and water? 回答1: Yes, you can change the color of map tiles. With Mapbox Studio you can design interactive maps. Also you can set any/single/multiple language for all the countries.

Leaflet.js - LatLng to Pixels

不羁的心 提交于 2021-02-11 15:45:55
问题 So I am using Pixels in my Leaflet using crs: L.CRS.Simple and unproject in all the places I reference coordinates, it is working great. However I am now trying to add a search bar and there is one line that I cannot figure out how to make it use pixels instead of LatLng (it's pulling pixel coords from a file) var title = data.newsroom, //value searched loc = [data.latitude, data.longitude] //position found marker = new L.Marker(new L.latLng(loc), {title: title, icon:icon} );//se property

Leaflet how to take individual values ​in GeoJSON?

自古美人都是妖i 提交于 2021-02-11 15:31:22
问题 I would like to do this in the Leaflet! I have a GeoJSON file with these data: "type": "Feature", "geometry": { "type": "MultiPoint", "coordinates": [ [ -123.77252789, 44.37857221 ], [ -123.77317087, 44.37864694 ], [ -123.77383407, 44.37875853 ] ] }, "properties": { "title" : "tillicum", "path_options" : { "color" : "red" }, "time": [ 1580403952000, 1580403990000, 1580404202000 ], "speed": [ 85, 88, 90 ], "altitude": [ 29, 50, 69 ], "heading": [ 0, 0, 0 ], "horizontal_accuracy": [ 87, 79, 59

React Leaflet - How to render custom image using Circle Markers

好久不见. 提交于 2021-02-11 13:56:18
问题 I am trying to generate a custom image for my CircleMarkers. I am not sure how to do it. I am using CircleMarkers here because I have almost 20K+ markers and need them for performance. I can't quite figure out how to pass a custom image to the CircleMarker. Any help on this is much appreciated. 回答1: There is no way to do this directly. APIs of leaflet.js or react-leaflet libraries do not respond to your request. You can do this by placing an extra marker child component in CircleMarker and