leaflet

Getting map coordinates from Leaflet.js?

可紊 提交于 2020-05-10 04:08:34
问题 I'm trying to use Leaflet to get the map coordinates of somewhere a user has right clicked. I've been going through the Leaflet API and so far I've figured out that I need to listen to the contextmenu event and use mouseEventToLatLng method to get the coordinates when clicked. However, when I go through and debug my code I'm not seeing an accessible latLng variable anywhere. Did I miss understand something in the API? function setMarkers() { document.getElementById("transitmap")

How to set up asymmetrical color gradient for a numerical variable in leaflet in R

ε祈祈猫儿з 提交于 2020-05-10 03:29:39
问题 I want to have leaflet color palette centered to zero (with Red-white-green diverging). I have tried what has been told in this post. When I tried this manual creation of colors, I got the red green divergence but couldn't able to center it to zero. My Code regions@data <- data.frame(region <- c("APAC (excl. China)", "Africa", "Americas", "Europe", "Greater China", "Middle East"), change_targeted <- c(36,-21,25,4,173,34)) color = "#666" weight = 0.5 opacity = 1 fillOpacity = 1 dashArray = ""

leaflet 地图操作(缩放、平移、定位/书签、动画)

生来就可爱ヽ(ⅴ<●) 提交于 2020-05-09 10:09:27
map.setZoom(10, { // animate: false }) //设置地图缩放到 map.zoomIn() //图层往里进一个图层,放大 map.zoomOut() //图层往里出一个图层,缩小 map.panTo([37.91082, 128.73583], { animate: true }) //地图平移,默认就是true, map.flyTo([36.52, 120.31]); // 点到点的抛物线动画,平移加缩放动画 //尽量避免 setZoom()等地图缩放方法与 flyTo、flyToBounds 一起合用,因为这两类地图操作方法都有各自的缩放值, //造成动画不流畅、不能定位到目的点。 let polygon = L.polygon( [[37, -109.05], [41, -109.03], [41, -102.05], [37, -102.04]], [40.774, -74.125], { color: 'green', fillColor: '#f03', fillOpacity: 0.5 }).addTo(map); //地图上绘制一个多形 map.flyToBounds(polygon.getBounds()); //getBounds(获取边界):返回地图视图的经纬度边界。 //飞到这个多变形区域上面,自动判断区域块的大小

Find the shortest path between points on a map made by the leaflet package

限于喜欢 提交于 2020-05-05 19:43:07
问题 I would like to know how do I get the shortest path between two points on a map made by the leaflet package. I have the map done (figure below), but I would like to calculate the shortest path, as well as show this route on the map. It is possible?? The executable code is below. library(leaflet) library(geosphere) #database df<-structure(list(Properties = c(1,2,3,4,5,6,7,8,9,10), Latitude = c(-23.2, -23.6, -23.9, -23.9, -23.6, -23.5, -23.9, -23.9, -23.6, -23.9), Longitude = c(-49.6, -49.6,

leaflet 使用GEOJSON创建矢量图形

醉酒当歌 提交于 2020-05-05 07:51:11
点对象: function g(feature, layer) { // does this feature have a property named popupContent? if (feature.properties && feature.properties.popupContent) { layer.bindPopup(feature.properties.popupContent); } } var geojsonFeature = { "type": "Feature", "properties": { "name": "Coors Field", "amenity": "Baseball Stadium", "popupContent": "This is where the Rockies play!" }, "geometry": { "type": "Point", "coordinates": [100, 31] } }; L.geoJSON(geojsonFeature, { onEachFeature: g }).addTo(map); 线要素: var draw_line = { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ [110, 11],

Plot scatterplot on a map in Shiny

孤人 提交于 2020-05-04 10:52:12
问题 how do I plot my scatterplot on a map? I managed to plot my scatterplot, however I wanted it to be plotted on a map. I believe that an option is to use the leaflet package, since I have the Latitude and Longitude coordinates, but I don't know how to use it. Please, if you have other options feel free. Could you help me with this problem ?? The executable code is below. Thank you very much! library(shiny) library(ggplot2) library(rdist) library(geosphere) library(kableExtra) library(readxl)

cesium 入门开发系列地图鹰眼功能(附源码下载)

穿精又带淫゛_ 提交于 2020-05-01 10:03:16
前言 cesium 入门开发系列环境知识点了解: cesium api文档介绍 ,详细介绍 cesium 每个类的函数以及属性等等 cesium 在线例子 内容概览 cesium 结合 leaflet 实现鹰眼图 cesium 自身 api 实现鹰眼图 源代码 demo 下载 cesium 结合 leaflet 实现鹰眼图方式 效果图如下 初始化 cesium function initialGlobeView() { Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3NjRjNGFjNy1jNDM3LTQzMTktODVlYS05YmFmOTAxYjk5MWUiLCJpZCI6Mzk5MSwic2NvcGVzIjpbImFzbCIsImFzciIsImFzdyIsImdjIl0sImlhdCI6MTUzOTU3OTE2NX0.-25udUzENRJ66mnICMK8Hfc6xgF_VP7P4sWkSHaUjOQ' ; var image_Source = new Cesium.UrlTemplateImageryProvider({ // url: 'http://mt0.google.cn/vt/lyrs=t,r&hl=zh-CN&gl=cn&x={x}&y={y}

leaflet-webpack 入门开发系列二加载不同在线地图切换显示(附源码下载)

♀尐吖头ヾ 提交于 2020-05-01 06:00:32
前言 leaflet-webpack 入门开发系列环境知识点了解: node 安装包下载 webpack 打包管理工具需要依赖 node 环境,所以 node 安装包必须安装,上面链接是官网下载地址 webpack 配置介绍文档 详细的 webpack 文档配置介绍,适合新手查看,我也是边看边学 vscode 安装包下载 ,我这边用 vscode工具编译开发前端项目,个人觉的这款工具还不错 leaflet api文档介绍 ,详细介绍 leaflet 每个类的函数以及属性等等 leaflet 在线例子 leaflet 插件 ,leaflet 的插件库,非常有用 内容概览 leaflet 加载不同在线地图切换显示 源代码 demo 下载 本篇 demo 加载在线地图分别是 OSM 地图、ArcGIS 地图、天地图、高德地图、谷歌地图以及百度地图,由于加载百度地图比较特殊,它采用的投影坐标系方案定义跟其他在线地图不一致,需要自定义 L.Proj.CRS,所以,为了简单化测试,加载百度地图是在另一个地图页面来的。 效果图如下: 百度地图效果: 其他在线地图效果: 实现思路 核心用到 leaflet 的 TileLayer 图层类,专门加载瓦片数据图层,还有就是 leaflet 底图切换控件Control.Layers,TileLayer 类具体使用,可以参照 api说明:

leaflet-webpack 入门开发系列三地图分屏对比(附源码下载)

孤者浪人 提交于 2020-05-01 06:00:19
前言 leaflet-webpack 入门开发系列环境知识点了解: node 安装包下载 webpack 打包管理工具需要依赖 node 环境,所以 node 安装包必须安装,上面链接是官网下载地址 webpack 配置介绍文档 详细的 webpack 文档配置介绍,适合新手查看,我也是边看边学 vscode 安装包下载 ,我这边用 vscode工具编译开发前端项目,个人觉的这款工具还不错 leaflet api文档介绍 ,详细介绍 leaflet 每个类的函数以及属性等等 leaflet 在线例子 leaflet 插件 ,leaflet 的插件库,非常有用 内容概览 leaflet 地图分屏对比 源代码 demo 下载 效果图 实现思路:创建左右并排的两个 div,各种渲染左右两个不同地图对象,然后同时监听左右两个地图的 drag 以及 mousemove 事件,在事件里面设置两个地图的当前范围一致 map. setView(_this.getCenter(),_this.getZoom()); html 地图界面 <html> <head> <title>Leaflet入门开发系列地图分屏</title> <style> html, body{ height: 100% ; margin: 0 ; padding: 0 ; } .left{ width: 50% ;

leaflet-webpack 入门开发系列六矢量瓦片(附源码下载)

二次信任 提交于 2020-05-01 05:22:22
前言 leaflet-webpack 入门开发系列环境知识点了解: node 安装包下载 webpack 打包管理工具需要依赖 node 环境,所以 node 安装包必须安装,上面链接是官网下载地址 webpack 配置介绍文档 详细的 webpack 文档配置介绍,适合新手查看,我也是边看边学 vscode 安装包下载 ,我这边用 vscode工具编译开发前端项目,个人觉的这款工具还不错 leaflet api文档介绍 ,详细介绍 leaflet 每个类的函数以及属性等等 leaflet 在线例子 leaflet 插件 ,leaflet 的插件库,非常有用 内容概览 leaflet 矢量瓦片 源代码 demo 下载 效果图如下: 本篇主要利用 leaflet 的插件 leaflet.vectorgrid 实现两种不同数据源的矢量瓦片渲染加载效果: 调用 geoserver 发布的 pbf 矢量瓦片服务 加载 geojson 数据源渲染矢量瓦片 leaflet.vectorgrid 插件 github 地址: https://github.com/Leaflet/Leaflet.VectorGrid 实现方式1:调用 geoserver 发布的 pbf 矢量瓦片服务 geoserver 安装矢量瓦片插件,用来拓展支持发布矢量瓦片服务,具体可以参考以下资料: https://www