leaflet

Popup on a shape using tmap

自作多情 提交于 2020-06-27 17:07:10
问题 I have made a map unsing tmap to include in a shiny app using leaflet . I have roughly what I want: a thematic map with fill color based on a SpatialPolygonsDataFrame, and when you click the map, a popup with extra information on the polygon. I would like to change the popup for a better layout when clicking. By default, the name in the dataset is displayed, but it is not really user friendly. Here is a reproducible example. library(tmap) library(leaflet) data(Europe) tmap_mode("view") carte

Popup on a shape using tmap

余生颓废 提交于 2020-06-27 17:05:05
问题 I have made a map unsing tmap to include in a shiny app using leaflet . I have roughly what I want: a thematic map with fill color based on a SpatialPolygonsDataFrame, and when you click the map, a popup with extra information on the polygon. I would like to change the popup for a better layout when clicking. By default, the name in the dataset is displayed, but it is not really user friendly. Here is a reproducible example. library(tmap) library(leaflet) data(Europe) tmap_mode("view") carte

Django - GeoDjango read coordinates in the wrong order

[亡魂溺海] 提交于 2020-06-26 12:25:27
问题 first of all thanks for your help. I'm making a form with Django which uses the OSMWidget to save coordinates (Polygons, Lines and Points) to a Geometry field in a PostgreSQL database. It works well, I can save the information in the database without any problem. And when I make a query with PgAdmin I can see the geometric fields data displayed in a Leaflet map correctly. . Here's some of what I have in my forms.py: from django import forms from django_select2 import forms as select2_forms

Django - GeoDjango read coordinates in the wrong order

[亡魂溺海] 提交于 2020-06-26 12:25:13
问题 first of all thanks for your help. I'm making a form with Django which uses the OSMWidget to save coordinates (Polygons, Lines and Points) to a Geometry field in a PostgreSQL database. It works well, I can save the information in the database without any problem. And when I make a query with PgAdmin I can see the geometric fields data displayed in a Leaflet map correctly. . Here's some of what I have in my forms.py: from django import forms from django_select2 import forms as select2_forms

Leaflet: how to swap coordinates received from an ajax call

大兔子大兔子 提交于 2020-06-25 07:08:35
问题 I am using Leaflet 1.0.3 and a few plugins including Leaflet.ajax. My L.geo.ajax call is working and returning geojson objects, however, the coordinates are reversed. I created a function to fix this: var convertLatLng = function (latlng) { var temp = latlng[y]; latlng[y] = latlng[x]; latlng[x] = temp; convertedLatLng = latlng; return convertedLatLng; console.log('this function is running') } But my problem is I don't know where to put it. Do I run it inside my geoJson call? If so, where?

React Leaflet: Add markers dynamically

守給你的承諾、 提交于 2020-06-24 22:27:16
问题 How to add markers dynamically to React-Leaflet maps? I want to add new markers when user clicks on map. And I cannot get it work. import React, { Component } from 'react' import { render } from 'react-dom'; import Control from 'react-leaflet-control'; import { Map, Marker, Popup, TileLayer, ZoomControl, ScaleControl } from 'react-leaflet'; import './Points.scss' export default class PointsMap extends Component { state = { lat: 50.2, lng: 30.2, zoom: 13, } handleClick = (e) => { this

Leaflet.js: Only show specific countries, dim or hide the rest

偶尔善良 提交于 2020-06-17 15:46:13
问题 Based on: Dim/Hide rest of map around country with leaflet.js While the accepted answer was almost spot on, its JSFiddle demo only works for old single polygon GeoJSON. Modern multipolygon GeoJSON allows for additional shapes to make up for overseas territories etc., and thus also introduces extra arrays which the JSFiddle demo doesn't know how to handle: // transform geojson coordinates into an array of L.LatLng var coordinates = france.features[0].geometry.coordinates[0]; var latLngs = [];

Uniquely identifying Leaflet Markers

南楼画角 提交于 2020-06-15 07:38:32
问题 I've done some research on this topic before, but I have yet to find an answer to my particular question. I am currently working with Leaflet.js. Each marker has popup text that is pulled from a MySQL database. However, some of this data does not display in the popup and is only associated with the marker. What I would like to do is whenever a particular marker is clicked, data that is associated with it is echoed in a location other than in the popup (ie. in a DIV). Is there a way to

change size of marker in leaflet

孤街醉人 提交于 2020-06-11 18:10:41
问题 I have one marker on the map in leaflet: var centerMarker = L.marker(centerPoint, { title: 'unselected' }).bindLabel(schools[i][0]); centerMarker.on('click', selectMarker); centerMarker.addTo(map); I want to change the size of that marker on click. I know that we can change icons but I just want to change the size of the same icon of the marker. 回答1: You can get the old icon from the marker itself, change the size of the icon and then call setIcon with the changed icon: var icon =

change size of marker in leaflet

老子叫甜甜 提交于 2020-06-11 18:10:27
问题 I have one marker on the map in leaflet: var centerMarker = L.marker(centerPoint, { title: 'unselected' }).bindLabel(schools[i][0]); centerMarker.on('click', selectMarker); centerMarker.addTo(map); I want to change the size of that marker on click. I know that we can change icons but I just want to change the size of the same icon of the marker. 回答1: You can get the old icon from the marker itself, change the size of the icon and then call setIcon with the changed icon: var icon =