leaflet 相关问题

Leaflet是一个开源JavaScript库,适用于移动设备友好的跨浏览器交互式地图。对于R传单包,请使用r-leaflet标签。

如何让 Leaflet Marker-Cluster Freezable 方法显示在 VS Code IntelliSense 中

我正在开发一个 Angular 项目,其中使用 Leaflet 地图服务。我遇到了聚类问题。我想切换集群,为此我找到了一个包,其中包含启用/

回答 2 投票 0

使用Leaflet.js和Leaflet GPX绘制带阴影的GPX轨迹

我正在使用 Leaflet.js 和 Leaflet GPX 在地图上显示许多 GPX 轨迹。轨迹应该有白色阴影,以便它们在地图上更好地突出。为此,每个轨道都添加到...

回答 1 投票 0

使用 pico.css 在传单中自定义放大缩小按钮

来自这个对传单中标记的自定义的答案:从标记中删除蓝色背景,现在我遇到以下问题: .html 文件: 来自传单中标记定制的答案:从标记中删除蓝色背景,现在我遇到以下问题: .html 文件: <!DOCTYPE html> <html lang="it"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css"> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/> <title>TITLE</title> </head> <body> <div id="map"></div> <script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script> <script src="mapscript.js"></script> </body> </html> 样式.css: #map { height: 500px; } [role=button],button,input[type=button],input[type=reset],input[type=submit]{ --background-color:none; --border-color:none; } [role=button]:is([aria-current],:hover,:active,:focus),button:is([aria-current],:hover,:active,:focus),input[type=button]:is([aria-current],:hover,:active,:focus),input[type=reset]:is([aria-current],:hover,:active,:focus),input[type=submit]:is([aria-current],:hover,:active,:focus){ --background-color:none; --border-color:none; } .leaflet-control-zoom-in, .leaflet-control-zoom-out { background-image: none; text-indent: -9999px; background-repeat: no-repeat; background-size: cover; border: none; } .leaflet-control-zoom-in { background-image: url('./immagini/plus-circle-svgrepo-com.svg'); } .leaflet-control-zoom-out { background-image: url('./immagini/minus-circle-svgrepo-com.svg'); } 我无法理解如何从放大和缩小按钮中删除背景,因为我使用的是具有透明背景的 svg 文件。 要修复使用 pico.css 后放大和缩小奇怪的外观,您可以使用以下行 padding: 0px 0px; 所以技巧是在 pico.css 之后应用以下内容 <style> [role=button],button,input[type=button],input[type=reset],input[type=submit]{ --background-color:none; --border-color:none; padding: 0px 0px; } [role=button]:is([aria-current],:hover,:active,:focus),button:is([aria-current],:hover,:active,:focus),input[type=button]:is([aria-current],:hover,:active,:focus),input[type=reset]:is([aria-current],:hover,:active,:focus),input[type=submit]:is([aria-current],:hover,:active,:focus){ --background-color:none; --border-color:none; } </style> 整个代码将是(作为示例): <!DOCTYPE html> <html lang="en"> <head> <base target="_top"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Quick Start - Leaflet</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css"> <link rel="stylesheet" href="pico.css"> <link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" /> <style> [role=button],button,input[type=button],input[type=reset],input[type=submit]{ --background-color:none; --border-color:none; padding: 0px 0px;; } [role=button]:is([aria-current],:hover,:active,:focus),button:is([aria-current],:hover,:active,:focus),input[type=button]:is([aria-current],:hover,:active,:focus),input[type=reset]:is([aria-current],:hover,:active,:focus),input[type=submit]:is([aria-current],:hover,:active,:focus){ --background-color:none; --border-color:none; } </style> <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/> <script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script> <style> html, body { height: 100%; margin: 0; } .leaflet-container { height: 400px; width: 600px; max-width: 100%; max-height: 100%; } </style> </head> <body> <div id="map" style="width: 600px; height: 400px;"></div> <script> const map = L.map('map').setView([51.505, -0.09], 13); const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' }).addTo(map); // const marker = L.marker([51.5, -0.09]).addTo(map); const LeafIcon = L.Icon.extend({ options: { // shadowUrl: '', iconSize: [32, 32], // shadowSize: [50, 64], iconAnchor: [22, 94], // shadowAnchor: [4, 62], popupAnchor: [-3, -76] } }); const greenIcon = new LeafIcon({iconUrl: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/library_maps.png'}); const mGreen = L.marker([51.5, -0.09], {icon: greenIcon}).bindPopup('StackOverflow.com is good').addTo(map); </script> </body> </html> 查看上面的结果

回答 1 投票 0

如何在npm上正确安装leaflet

我正在尝试在 npm 上安装 leaflet 库,但由于某种原因它给出了错误。我已经重新安装了npm,清除了缓存,删除了node_modules并再次尝试,但仍然不起作用。 nasersobhan@N...

回答 1 投票 0

如何在地图加载时打开特定的弹出窗口?

将 React-Leaflet V3.1.0 与 Express 服务器结合使用。 我的用户请求能够使用以下格式的链接: https://www.mymap.com/id/:category/:id/:zoom 这会向

回答 2 投票 0

如何使用React传单仅显示一个国家?

我在我的一个项目中使用react-leaflet,我想仅显示一个国家并删除其余国家或隐藏。 有人已经解决了这个问题,但不幸的是它不适用于 React。你知道怎么做吗

回答 2 投票 0

更改图层时显示不同的图例 - 传单

我试图让我的传单地图在选择两个图层时不显示图例,而当仅选择一个图层时显示该图层的图例。 我使用 Javascript 找到了这些解决方案: 如何切换

回答 1 投票 0

在传单中显示海拔

目前我正在使用 Agisoft 将 DEM 导出为 TIF。从这里可以在传单中显示高程模型还是需要其他步骤?

回答 1 投票 0

使用自定义请求标头反应传单 WMSTileLayer

我正在尝试使用我的 wms 磁贴请求发送身份验证标头。 当我使用纯传单库时,使用 leaflet-wms-header 非常简单 但是,我已经切换到react-leaflet并且它有它......

回答 1 投票 0

从标记中删除蓝色背景

如何去除标记中的蓝色背景? 使用默认图标和自定义图标(具有透明背景的 png)会发生这种情况 难道我做错了什么? 如何去除标记中的蓝色背景? 使用默认图标和自定义图标(具有透明背景的 png)会发生这种情况 我做错了什么吗? <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css"> <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> <title>Map with OpenStreetMap</title> <style> #map { height: 400px; } </style> </head> <body> <div id="map"></div> <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> <script> var map = L.map('map').setView([45.418393, 10.969487], 13); // Replace with your default map center L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap contributors' }).addTo(map); var marker = L.marker([45.410051797705904, 10.90330758434609]).addTo(map); </script> </body> </html> 尝试使用自定义图标,但仍然遇到同样的问题 var LogoPin = L.icon({ backgroundColor: 'transparent', iconUrl: './pin.png', shadowUrl: './shad.png', iconSize: [30, 47], // size of the icon [38,95] shadowSize: [50, 64], // size of the shadow*/ iconAnchor: [22, 94], // point of the icon which will correspond to marker's location shadowAnchor: [4, 62], // the same for the shadow*/ popupAnchor: [-3, -76] // point from which the popup should open relative to the iconAnchor }); L.marker([place.lat, place.lng], {icon: LogoPin}).addTo(map); 对于OpenStreetMap,使用自定义标记(yourown.png)的方法之一是使用OpenLayers.icon指定标记png(透明),然后将此图标用作OpenLayers.Marker,如下: var size = new OpenLayers.Size(32,32); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var icon = new OpenLayers.Icon("https://developers.google.com/maps/documentation/javascript/examples/full/images/library_maps.png", size, offset); var markers = new OpenLayers.Layer.Markers("Markers") map.addLayer(markers); markers.addMarker(new OpenLayers.Marker(position, icon)); 所以你可以尝试以下(完全工作的代码) <div id="Map" style="height: 250px; width: 400px" ></div> <script src="http://www.openlayers.org/api/OpenLayers.js"></script> <!--<script src="js/osm/api/OpenLayers.js"></script>--> <script> var lat = 55.676098; var lon = 12.568337; var zoom = 11; var fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984 var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection); map = new OpenLayers.Map("Map"); var mapnik = new OpenLayers.Layer.OSM(); map.addLayer(mapnik); ////////////////// var size = new OpenLayers.Size(32,32); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var icon = new OpenLayers.Icon("https://developers.google.com/maps/documentation/javascript/examples/full/images/library_maps.png", size, offset); var markers = new OpenLayers.Layer.Markers("Markers") map.addLayer(markers); markers.addMarker(new OpenLayers.Marker(position, icon)); ////////////////// disable default marker // var markers = new OpenLayers.Layer.Markers("Markers");//("Images/Icons/map-marker.png"); // map.addLayer(markers); // markers.addMarker(new OpenLayers.Marker(position)); //////////////// END map.setCenter(position, zoom); </script>

回答 1 投票 0

如何设置geoJson图层的zIndex图层顺序?

我希望某些图层始终位于其他图层之上,无论它们以何种顺序添加到地图中。 我知道bringToFront(),但它不满足我的要求。我会...

回答 3 投票 0

Heroku 上缺少 GDAL

运行的 Django 应用程序通过 django-geojson 将 GeoJSON 数据存储在模型之一中。在管理界面中,该字段可通过 django-leaflet 进行编辑。当我在本地运行应用程序时...

回答 4 投票 0

如何在Leaflet.markercluster上自定义覆盖区域样式?

我的目标是自定义将鼠标悬停在 Leaflet.markercluster 中的集群上时显示在地图上的覆盖区域边界的默认颜色。如下图所示: 审核后...

回答 1 投票 0

reactive 和 leafletProxy,在创建 leaflet 应用程序时观察 Rshiny 中的问题

使用if语句、observe和leafletProxy的形式,但我似乎无法让它工作。我有两个独立的数据库,其中一个是 PLOT,另一个是 ISTANBUL_OIM。情节很长。和纬度。

回答 1 投票 0

使用R Shiny默认显示所有数据点

我想使用 R Shiny 绘制一些数据点的空间分布图。当我将不同区域的过滤器添加到 R 脚本中时,它无法显示

回答 1 投票 0

点击时未打开传单弹出窗口(Safari 13.1.3)

编辑- https://codepen.io/jdog6652/pen/YzNbPQg - 实时示例取消注释 JS 底部的函数调用 编辑2-感谢大家的帮助,在我的版本上,这似乎是一个浏览器问题

回答 2 投票 0

标记不会出现在传单中的连续世界中

当我设置选项 ContinuousWorld=true 时,标记不会显示在克隆图块上,仅显示在主世界上。这是设计好的行为吗?可能是其他选项(我没有注意到)来显示这些标记

回答 3 投票 0

如何获取传单WMS地图最近的特征?

我对 Web 服务还很陌生,我遇到了一个问题。 我有一张与 WMS 链接的地图。 我添加了底图和 WMS 日期作为tileLayer,并在我的地图上正确显示。 现在我想要最近的

回答 1 投票 0

传单中的 Graphopper 选项

我有一个传单地图,使用graphopper作为路由器。我在设置选项时遇到问题;例如,将车辆从默认(汽车)更改为摩托车。 路线控制 = 新 L.Routing.C...

回答 2 投票 0

如何在nextjs中使用tailwind从react-leaflet中设置弹出窗口的样式

我正在尝试使用顺风在地图中设置弹出窗口的样式,但样式没有反映。 const 自定义图标 = divIcon({ html: ` 我正在尝试使用顺风在地图中设置弹出窗口的样式,但样式没有反映。 const customIcon = divIcon({ html: ` <svg width="54" height="55" viewBox="0 0 54 55" fill="none" xmlns="http://www.w3.org/2000/svg" > <g clip-path="url(#clip0_817_1163)"> <path d="M27.0001 54.2632C27.0001 54.2632 8.1001 29.6122 8.1001 19.1632C8.1001 16.6812 8.58896 14.2235 9.53877 11.9305C10.4886 9.63741 11.8808 7.55389 13.6358 5.79887C15.3908 4.04384 17.4743 2.65167 19.7674 1.70186C22.0604 0.752047 24.5181 0.263184 27.0001 0.263184C29.4821 0.263184 31.9398 0.752047 34.2328 1.70186C36.5259 2.65167 38.6094 4.04384 40.3644 5.79887C42.1194 7.55389 43.5116 9.63741 44.4614 11.9305C45.4112 14.2235 45.9001 16.6812 45.9001 19.1632C45.9001 29.6122 27.0001 54.2632 27.0001 54.2632ZM27.0001 24.5632C28.4323 24.5632 29.8058 23.9943 30.8185 22.9816C31.8312 21.9689 32.4001 20.5954 32.4001 19.1632C32.4001 17.731 31.8312 16.3575 30.8185 15.3448C29.8058 14.3321 28.4323 13.7632 27.0001 13.7632C25.5679 13.7632 24.1944 14.3321 23.1817 15.3448C22.169 16.3575 21.6001 17.731 21.6001 19.1632C21.6001 20.5954 22.169 21.9689 23.1817 22.9816C24.1944 23.9943 25.5679 24.5632 27.0001 24.5632Z" fill="#1B1130" /> </g> <defs> <clipPath id="clip0_817_1163"> <rect width="54" height="54" fill="white" transform="translate(0 0.263184)" /> </clipPath> </defs> </svg>`, popupAnchor: [140, 126], }); <MapContainer center={[48.8566, 2.3522]} zoom={10} scrollWheelZoom={false}> <TileLayer attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" /> <Marker position={[48.8566, 2.3522]} icon={customIcon}> <Popup className=""> <h2 className="">hi how are you?</h2> <p className="">welcome to paris</p> </Popup> </Marker> </MapContainer> 我试图向整个弹出窗口添加背景颜色,但颜色没有反映到整个弹出窗口。 您找到解决方案了吗? 我也有同样的问题。

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.