pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <small id='H7Wab'></small><noframes id='H7Wab'>

    <i id='H7Wab'><tr id='H7Wab'><dt id='H7Wab'><q id='H7Wab'><span id='H7Wab'><b id='H7Wab'><form id='H7Wab'><ins id='H7Wab'></ins><ul id='H7Wab'></ul><sub id='H7Wab'></sub></form><legend id='H7Wab'></legend><bdo id='H7Wab'><pre id='H7Wab'><center id='H7Wab'></center></pre></bdo></b><th id='H7Wab'></th></span></q></dt></tr></i><div class="scjw7ub" id='H7Wab'><tfoot id='H7Wab'></tfoot><dl id='H7Wab'><fieldset id='H7Wab'></fieldset></dl></div>
    1. <tfoot id='H7Wab'></tfoot>

      • <bdo id='H7Wab'></bdo><ul id='H7Wab'></ul>
      <legend id='H7Wab'><style id='H7Wab'><dir id='H7Wab'><q id='H7Wab'></q></dir></style></legend>

      1. 如何從地圖外部與傳單標記層進行交互?

        How to interact with leaflet marker layer from outside the map?(如何從地圖外部與傳單標記層進行交互?)
        <i id='v4eZT'><tr id='v4eZT'><dt id='v4eZT'><q id='v4eZT'><span id='v4eZT'><b id='v4eZT'><form id='v4eZT'><ins id='v4eZT'></ins><ul id='v4eZT'></ul><sub id='v4eZT'></sub></form><legend id='v4eZT'></legend><bdo id='v4eZT'><pre id='v4eZT'><center id='v4eZT'></center></pre></bdo></b><th id='v4eZT'></th></span></q></dt></tr></i><div class="qmilvtr" id='v4eZT'><tfoot id='v4eZT'></tfoot><dl id='v4eZT'><fieldset id='v4eZT'></fieldset></dl></div>

        • <bdo id='v4eZT'></bdo><ul id='v4eZT'></ul>

          <tfoot id='v4eZT'></tfoot>
              <tbody id='v4eZT'></tbody>
            <legend id='v4eZT'><style id='v4eZT'><dir id='v4eZT'><q id='v4eZT'></q></dir></style></legend>
            • <small id='v4eZT'></small><noframes id='v4eZT'>

                  本文介紹了如何從地圖外部與傳單標記層進行交互?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有一張傳單地圖,顯示公共藝術作品的點,從 GeoJSON 渲染.在地圖旁邊,我從相同的 GeoJSON 數據創建了一個片段列表,并且希望能夠單擊地圖外列表中的項目,并在地圖上顯示相關標記的彈出窗口.

                  I have a leaflet map showing points for public art pieces, rendered from GeoJSON. Next to the map, I created a list of the pieces from the same GeoJSON data and want to be able to click on an item from the list outside of the map and have the related marker's popup come up on the map.

                  如何通過點擊事件將項目列表鏈接到它們各自的標記?

                  How can I link the list of items to their respective markers through a click event?

                  我的 map.js 文件如下所示:

                  My map.js file looks like this:

                  var map;
                  var pointsLayer;
                  
                  $(document).ready(function () {
                      map = new L.Map('mapContainer');
                      var url = 'http://{s}.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png';
                      var copyright = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade';
                      var tileLayer = new L.TileLayer(url, {
                          attribution: copyright
                      });
                      var startPosition = new L.LatLng(41.883333, - 87.633333);
                      map.on('load', function (e) {
                          requestUpdatedPoints(e.target.getBounds())
                      });
                      map.setView(startPosition, 13).addLayer(tileLayer);
                      map.on('moveend', function (e) {
                          requestUpdatedPoints(e.target.getBounds())
                      })
                  });
                  
                  function requestUpdatedPoints(bounds) {
                      $.ajax({
                          type: 'GET',
                          url: '/SeeAll',
                          dataType: 'json',
                          data: JSON.stringify(bounds),
                          contentType: 'application/json; charset=utf-8',
                          success: function (result) {
                              parseNewPoints(result);
                              addToList(result)
                          },
                          error: function (req, status, error) {
                              alert('what happen? did you lose conn. to server ?')
                          }
                      })
                  }
                  
                  function addToList(data) {
                      for (var i = 0; i < data.features.length; i++) {
                          var art = data.features[i];
                          $('div#infoContainer').append('<a href="#" class="list-link" title="' + art.properties.descfin + '"><div class="info-list-item">' + '<div class="info-list-txt">' + '<div class="title">' + art.properties.wrknm + '</div>' + '<br />' + art.properties.location + '</div>' + '<div class="info-list-img">' + art.properties.img_src + '</div>' + '<br />' + '</div></a>')
                      }
                      $('a.list-link').click(function (e) {
                          alert('now you see what happens when you click a list item!');
                          e.preventDefault()
                      })
                  }
                  
                  function parseNewPoints(data) {
                      if (pointsLayer != undefined) {
                          map.removeLayer(pointsLayer)
                      }
                      pointsLayer = new L.GeoJSON();
                      var geojsonMarkerOptions = {
                          radius: 8,
                          fillColor: "#FF6788",
                          color: "YELLOW",
                          weight: 1,
                          opacity: 1,
                          fillOpacity: 0.5
                      };
                      L.geoJson(data, {
                          pointToLayer: function (feature, latlng) {
                              return L.circleMarker(latlng, geojsonMarkerOptions)
                          },
                          onEachFeature: function (feature, pointsLayer) {
                              pointsLayer.bindPopup(feature.properties.img_src + "<br />" + feature.properties.wrknm + "<br />" + feature.properties.artist + "<br />" + feature.properties.location + '<div class="description">' + feature.properties.descfin + '</div>')
                          }
                      }).addTo(map)
                  }
                  

                  推薦答案

                  Felix Kling 是對的,但我會稍微擴展他的評論......

                  Felix Kling is right but I'll expand on his comment a little bit...

                  由于 L.LayerGroup 和 L.FeatureGroup(從 L.GeoJSON 擴展而來)沒有檢索各個層的方法,您需要從 L.GeoJSON 擴展并添加這樣的方法,或者保留您自己的單獨映射從 GeoJSON 到 CircleMarker 的唯一 ID.

                  Since L.LayerGroup and L.FeatureGroup (which L.GeoJSON extends from) don't have methods to retrieve individual layers you will need to either extend from L.GeoJSON and add such a method or keep your own seperate mapping from unique ID to CircleMarker from GeoJSON.

                  GeoJSON 不需要唯一 ID,但我假設您的提要中的標記具有稱為id"的唯一 ID 屬性.您需要將此唯一 ID 添加到用戶可以單擊的鏈接中,以便鏈接可以選擇地圖上的正確標記.然后,您需要將 id 映射存儲到標記,以便檢索標記以在地圖上選擇它.

                  GeoJSON does not require a unique ID but I'll assume that markers in your feed have a unique ID attribute called "id". You will need to add this unique ID to the links that the user can click on so that the links can select the right marker on the map. Then you'll need to store a map of ids to markers in order to retrieve the marker to select it on the map.

                  markerMap = {}; // a global variable unless you extend L.GeoJSON
                  
                  // Add the marker id as a data item (called "data-artId") to the "a" element
                  function addToList(data) {
                      for (var i = 0; i < data.features.length; i++) {
                          var art = data.features[i];
                          $('div#infoContainer').append('<a href="#" class="list-link" data-artId="'+art.id+'" title="' + art.properties.descfin + '"><div class="info-list-item">' + '<div class="info-list-txt">' + '<div class="title">' + art.properties.wrknm + '</div>' + '<br />' + art.properties.location + '</div>' + '<div class="info-list-img">' + art.properties.img_src + '</div>' + '<br />' + '</div></a>')
                      }
                      $('a.list-link').click(function (e) {
                          alert('now you see what happens when you click a list item!');
                  
                          //Get the id of the element clicked
                          var artId = $(this).data( 'artId' );
                          var marker = markerMap[artId];
                  
                          //since you're using CircleMarkers the OpenPopup method requires
                          //a latlng so I'll just use the center of the circle
                          marker.openPopup(marker.getLatLng());
                          e.preventDefault()
                      })
                  }
                  

                  從服務器獲取數據時需要構建markerMap.您的 pointToLayer 方法可以修改為:

                  You need to build the markerMap when you get the data from the server. Your pointToLayer method could be modified to do that:

                  L.geoJson(data, {
                      pointToLayer: function (feature, latlng) {
                        var marker = new L.CircleMarker( latlng, geojsonMarkerOptions );
                        markerMap[feature.id] = marker;
                        return marker;
                      },...
                  

                  這篇關于如何從地圖外部與傳單標記層進行交互?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                  Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                  Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)
                  Detect FLASH plugin crashes(檢測 FLASH 插件崩潰)
                1. <small id='02v7b'></small><noframes id='02v7b'>

                  <i id='02v7b'><tr id='02v7b'><dt id='02v7b'><q id='02v7b'><span id='02v7b'><b id='02v7b'><form id='02v7b'><ins id='02v7b'></ins><ul id='02v7b'></ul><sub id='02v7b'></sub></form><legend id='02v7b'></legend><bdo id='02v7b'><pre id='02v7b'><center id='02v7b'></center></pre></bdo></b><th id='02v7b'></th></span></q></dt></tr></i><div class="8xhrfsy" id='02v7b'><tfoot id='02v7b'></tfoot><dl id='02v7b'><fieldset id='02v7b'></fieldset></dl></div>
                    <tbody id='02v7b'></tbody>
                  <tfoot id='02v7b'></tfoot>
                2. <legend id='02v7b'><style id='02v7b'><dir id='02v7b'><q id='02v7b'></q></dir></style></legend>

                    • <bdo id='02v7b'></bdo><ul id='02v7b'></ul>
                          • 主站蜘蛛池模板: 行业分析:提及郑州火车站附近真有 特殊按摩 ?2025实地踩坑指南 新手如何避坑不踩雷 | 德国进口电锅炉_商用电热水器_壁挂炉_电采暖器_电热锅炉[德国宝] | R507制冷剂,R22/R152a制冷剂厂家-浙江瀚凯制冷科技有限公司 | 吨袋包装机|吨包秤|吨包机|集装袋包装机-烟台华恩科技 | 隆众资讯-首页_大宗商品资讯_价格走势_市场行情 | 超声波清洗机_超声波清洗机设备_超声波清洗机厂家_鼎泰恒胜 | 保温杯,儿童婴童奶瓶,运动水壶「广告礼品杯定制厂家」超朗保温杯壶 | 武汉EPS线条_EPS装饰线条_EPS构件_湖北博欧EPS线条厂家 | 硫化罐_蒸汽硫化罐_大型硫化罐-山东鑫泰鑫智能装备有限公司 | 大型冰雕-景区冰雕展制作公司,3D创意设计源头厂家-[赛北冰雕] | 塑胶跑道_学校塑胶跑道_塑胶球场_运动场材料厂家_中国塑胶跑道十大生产厂家_混合型塑胶跑道_透气型塑胶跑道-广东绿晨体育设施有限公司 | 超声骨密度仪-骨密度检测仪-经颅多普勒-tcd仪_南京科进实业有限公司 | 不锈钢管件(不锈钢弯头,不锈钢三通,不锈钢大小头),不锈钢法兰「厂家」-浙江志通管阀 | 微信聊天记录恢复_手机短信删除怎么恢复_通讯录恢复软件下载-快易数据恢复 | 瑞典Blueair空气净化器租赁服务中心-专注新装修办公室除醛去异味服务! | 喷播机厂家_二手喷播机租赁_水泥浆洒布机-河南青山绿水机电设备有限公司 | ETFE膜结构_PTFE膜结构_空间钢结构_膜结构_张拉膜_浙江萬豪空间结构集团有限公司 | 电镀电源整流器_高频电解电源_单脉双脉冲电源 - 东阳市旭东电子科技 | 浙江宝泉阀门有限公司| 鹤壁创新仪器公司-全自动量热仪,定硫仪,煤炭测硫仪,灰熔点测定仪,快速自动测氢仪,工业分析仪,煤质化验仪器 | 内窥镜-工业内窥镜厂家【上海修远仪器仪表有限公司】 | 杭州中策电线|中策电缆|中策电线|杭州中策电缆|杭州中策电缆永通集团有限公司 | 济南货架定做_仓储货架生产厂_重型货架厂_仓库货架批发_济南启力仓储设备有限公司 | 工控机-工业平板电脑-研华工控机-研越无风扇嵌入式box工控机 | 威客电竞(vk·game)·电子竞技赛事官网| 蔡司三坐标-影像测量机-3D扫描仪-蔡司显微镜-扫描电镜-工业CT-ZEISS授权代理商三本工业测量 | 密封无忧网 _ 专业的密封产品行业信息网 | 艾默生变频器,艾默生ct,变频器,ct驱动器,广州艾默生变频器,供水专用变频器,风机变频器,电梯变频器,艾默生变频器代理-广州市盟雄贸易有限公司官方网站-艾默生变频器应用解决方案服务商 | 冷却塔厂家_冷却塔维修_冷却塔改造_凉水塔配件填料公司- 广东康明节能空调有限公司 | 冷库安装厂家_杭州冷库_保鲜库建设-浙江克冷制冷设备有限公司 | 品牌广告服务平台,好排名,好流量,好生意。 | 天津力值检测-天津管道检测-天津天诚工程检测技术有限公司 | 冷却塔减速机器_冷却塔皮带箱维修厂家_凉水塔风机电机更换-广东康明冷却塔厂家 | 杭州高温泵_热水泵_高温油泵|昆山奥兰克泵业制造有限公司 | 中视电广_短视频拍摄_短视频推广_短视频代运营_宣传片拍摄_影视广告制作_中视电广 | 招商帮-一站式网络营销服务|互联网整合营销|网络推广代运营|信息流推广|招商帮企业招商好帮手|搜索营销推广|短视视频营销推广 | 升降机-高空作业车租赁-蜘蛛车-曲臂式伸缩臂剪叉式液压升降平台-脚手架-【普雷斯特公司厂家】 | 首页-恒温恒湿试验箱_恒温恒湿箱_高低温试验箱_高低温交变湿热试验箱_苏州正合 | 西装定制/做厂家/公司_西装订做/制价格/费用-北京圣达信西装 | 120kv/2mA直流高压发生器-60kv/2mA-30kva/50kv工频耐压试验装置-旭明电工 | 北京翻译公司_同传翻译_字幕翻译_合同翻译_英语陪同翻译_影视翻译_翻译盖章-译铭信息 |