日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Leaflet中使用leaflet-cion-pulse插件实现波动的图标效果

發(fā)布時間:2025/3/19 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Leaflet中使用leaflet-cion-pulse插件实现波动的图标效果 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

場景

Leaflet快速入門與加載OSM顯示地圖:

Leaflet快速入門與加載OSM顯示地圖_BADAO_LIUMANG_QIZHI的博客-CSDN博客

在上面的基礎上,怎樣使用插件實現(xiàn)波動的圖標效果如下

注:

博客:
BADAO_LIUMANG_QIZHI的博客_霸道流氓氣質_CSDN博客-C#,SpringBoot,架構之路領域博主
關注公眾號
霸道的程序猿
獲取編程相關電子書、教程推送與免費下載。

實現(xiàn)

1、插件地址

https://github.com/mapshakers/leaflet-icon-pulse

2、下載插件代碼,引入需要的js文件L.Icon.Pulse.js

3、這里直接把css文件放在html中,不再單獨引入

??????? .leaflet-pulsing-icon {border-radius: 100%;box-shadow: 1px 1px 8px 0 rgba(0, 0, 0, 0.75);}.leaflet-pulsing-icon:after {content: "";border-radius: 100%;height: 300%;width: 300%;position: absolute;margin: -100% 0 0 -100%;}@keyframes pulsate {0% {transform: scale(0.1, 0.1);opacity: 0;-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter: alpha(opacity=0);}50% {opacity: 1;-ms-filter: none;filter: none;}100% {transform: scale(1.2, 1.2);opacity: 0;-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter: alpha(opacity=0);}}

4、聲明波動圖標并添加到地圖

??????? //波動圖標聲明并設置樣式var pulsingIcon = L.icon.pulse({iconSize: [20, 20],color: 'red'});//圖標添加到地圖上var marker = L.marker([36.09, 120.35], {icon: pulsingIcon}).addTo(map);

5、完整示例代碼

? <!doctype html> <html lang="en"><head><meta charset="UTF-8"><title>leaflet加載osm</title><link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" /><style>html,body,#map {padding: 0;margin: 0;width: 100%;height: 100%;overflow: hidden;}.leaflet-pulsing-icon {border-radius: 100%;box-shadow: 1px 1px 8px 0 rgba(0, 0, 0, 0.75);}.leaflet-pulsing-icon:after {content: "";border-radius: 100%;height: 300%;width: 300%;position: absolute;margin: -100% 0 0 -100%;}@keyframes pulsate {0% {transform: scale(0.1, 0.1);opacity: 0;-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter: alpha(opacity=0);}50% {opacity: 1;-ms-filter: none;filter: none;}100% {transform: scale(1.2, 1.2);opacity: 0;-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter: alpha(opacity=0);}}</style> </head><body><div id="map"></div><script type="text/javascript" src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script><script type="text/javascript" src="./js/L.Icon.Pulse.js"></script><script type="text/javascript">var map = L.map('map').setView([36.09, 120.35], 13);L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: ''}).addTo(map);//波動圖標聲明并設置樣式var pulsingIcon = L.icon.pulse({iconSize: [20, 20],color: 'red'});//圖標添加到地圖上var marker = L.marker([36.09, 120.35], {icon: pulsingIcon}).addTo(map);</script> </body></html>?

總結

以上是生活随笔為你收集整理的Leaflet中使用leaflet-cion-pulse插件实现波动的图标效果的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。