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

<small id='Rb0jX'></small><noframes id='Rb0jX'>

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

        • <bdo id='Rb0jX'></bdo><ul id='Rb0jX'></ul>
      1. <legend id='Rb0jX'><style id='Rb0jX'><dir id='Rb0jX'><q id='Rb0jX'></q></dir></style></legend>

      2. 如何將 map.locate 與 Polymer 1.0/leaflet-map 1.0 一起使用

        how to use map.locate with Polymer 1.0 / leaflet-map 1.0(如何將 map.locate 與 Polymer 1.0/leaflet-map 1.0 一起使用)
        <tfoot id='BBzSX'></tfoot>
          <bdo id='BBzSX'></bdo><ul id='BBzSX'></ul>
          <i id='BBzSX'><tr id='BBzSX'><dt id='BBzSX'><q id='BBzSX'><span id='BBzSX'><b id='BBzSX'><form id='BBzSX'><ins id='BBzSX'></ins><ul id='BBzSX'></ul><sub id='BBzSX'></sub></form><legend id='BBzSX'></legend><bdo id='BBzSX'><pre id='BBzSX'><center id='BBzSX'></center></pre></bdo></b><th id='BBzSX'></th></span></q></dt></tr></i><div class="mkigwoq" id='BBzSX'><tfoot id='BBzSX'></tfoot><dl id='BBzSX'><fieldset id='BBzSX'></fieldset></dl></div>

                <small id='BBzSX'></small><noframes id='BBzSX'>

                  <tbody id='BBzSX'></tbody>

                1. <legend id='BBzSX'><style id='BBzSX'><dir id='BBzSX'><q id='BBzSX'></q></dir></style></legend>

                  本文介紹了如何將 map.locate 與 Polymer 1.0/leaflet-map 1.0 一起使用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我對 Polymer 和 Leaflet 的 web 組件都是新手.

                  I am new to both Polymer and Leaflet's web component.

                  我想要一個按鈕來切換 Leaflet 提供的地理定位功能.在 Javascript/HTML/css 應用程序中使用 Leaflet 我會知道如何做到這一點,但我無法使用 Polymer 1.0 讓它工作.

                  I would like to have a button that toggles the geolocation function given by Leaflet. Using Leaflet in a Javascript/HTML/css application I would know how to do this but I can't get it to work using Polymer 1.0.

                  這是我的地圖元素.我調用 map.locate 的嘗試在元素注冊中被注釋掉了:

                  Here is my map element. My attempt to call map.locate is commented out in the element registration:

                  <dom-module id="my-maps">
                   <style>
                     ...
                   </style>
                    <template>
                      <leaflet-map id="thismap" latitude="{{latitude}}" longitude="{{longitude}}" zoom="14"> 
                        <leaflet-geolocation enable-high-accuracy latitude="{{latitude}}" longitude="{{longitude}}" watch="true">
                        </leaflet-geolocation>     
                        <template is="dom-if" if="{{latitude}}">
                          <leaflet-marker latitude="{{latitude}}" longitude="{{longitude}}">                 
                          </leaflet-marker>
                        </template>
                      </leaflet-map>
                    </template>
                    <script>
                       Polymer({
                        is: "my-maps",
                        ready: function () {
                             L.Icon.Default.imagePath="../../bower_components/leaflet/dist/images";      
                             // **this.$.thismap.locate({setView: true}); // not working**
                         } 
                  
                     });
                    </script>
                  </dom-module>
                  

                  對于這個例子,我得到這個錯誤:無法讀取未定義的屬性thismap"

                  For this example I get this error: Cannot read property 'thismap' of undefined

                  如果我直接引用'this'(this.locate()),返回的錯誤是:this.locate 不是函數

                  If I refer to 'this' directly (this.locate()), the error returned is: this.locate is not a function

                  (此片段只是一個測試;理想情況下,定位函數將由來自 'geoButton' 元素的點擊事件調用):

                  (this snippet is just a test; ideally the locate function would be called by a click event from the 'geoButton' element) :

                        <div flex>
                             <ir-maps id="mymap" class="basemap" flex></ir-maps> 
                             <ir-geoButton class="geoButton" ></ir-geoButton>
                        </div>
                  

                  推薦答案

                  我的解決方案沒有明確使用 map.locate.這不是必需的,因為 map.locate 是通過添加 leaflet-geolocation 元素啟用的.

                  My solution does not use map.locate explicitly. This was not needed, as map.locate is enabled by adding the leaflet-geolocation element.

                  我從小冊子地圖元素中刪除了緯度和經度屬性(并添加了一些其他參數):

                  I removed the latitude and longitude property from the leaflet-map element (and added a few other parameters):

                          <leaflet-map 
                  
                          id="nycmap" zoom="14" 
                          min-zoom="14" 
                          max-zoom="18" 
                          nozoomControl="true"
                          noattributionControl:="false">
                  

                  然后我在leaflet-map元素(leaflet-core.html)的注冊中添加了一個一次性監聽器,這樣如果啟用了地理定位,地圖就會縮放到那個位置,如果沒有,它會縮放到那個位置縮放到默認中心點.'geoB' 是一個切換地理定位功能的按鈕:

                  Then I added a one-time listener to the registration of the leaflet-map element (leaflet-core.html), so that if geolocation is enabled, the map will zoom to that location, and if it is not it will zoom to a default center point. 'geoB' is a button that toggles the geolocation function:

                              map.addOneTimeEventListener('locationfound', function (e){
                  
                              console.log("get to located found?");           
                              map.setView(L.latLng(e.latitude, e.longitude), 14);
                              var geo = document.getElementById('geoB');
                              var state = geo.classList.toggle('toggleState');
                          }, this);
                  
                  
                  
                          map.on('locationerror', function(e){
                              console.log("get to located error?");
                              map.setView(L.latLng(40.6889, -73.9444), 14);
                              map.stopLocate();
                          }, this);
                  

                  我向 Leaflet-map 元素添加了另一個功能,以便我可以將當??前緯度和經度傳遞給元素并縮放到該點,點擊地理定位按鈕:

                  I added another function to the leaflet-map element so that I can pass the current latitude and longitude to the element and zoom to that point, on the click on the geolocation button:

                      setToPoint: function(newLat, newLong){
                          if (this.map && !this._ignoreViewChange) {
                              this.async(function() {
                                 this.map.setView(L.latLng(newLat, newLong), this.zoom, {pan: {animate: true}});
                                 this.map.invalidateSize();
                             });
                  
                          }
                  
                      },
                  

                  最后,這個函數在 geoButton 元素的事件監聽器中被調用,它引用了 leaflet-geolocation 元素:

                  Finally, this function is called in an event listener in the geoButton element, which references the leaflet-geolocation element:

                  nycmap.setToPoint(locator.latitude, locator.longitude);
                  

                  這篇關于如何將 map.locate 與 Polymer 1.0/leaflet-map 1.0 一起使用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                  Trigger click on leaflet marker(觸發點擊傳單標記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                  <tfoot id='vChxT'></tfoot>
                    <bdo id='vChxT'></bdo><ul id='vChxT'></ul>

                      • <legend id='vChxT'><style id='vChxT'><dir id='vChxT'><q id='vChxT'></q></dir></style></legend>

                        1. <small id='vChxT'></small><noframes id='vChxT'>

                          <i id='vChxT'><tr id='vChxT'><dt id='vChxT'><q id='vChxT'><span id='vChxT'><b id='vChxT'><form id='vChxT'><ins id='vChxT'></ins><ul id='vChxT'></ul><sub id='vChxT'></sub></form><legend id='vChxT'></legend><bdo id='vChxT'><pre id='vChxT'><center id='vChxT'></center></pre></bdo></b><th id='vChxT'></th></span></q></dt></tr></i><div class="ucaekea" id='vChxT'><tfoot id='vChxT'></tfoot><dl id='vChxT'><fieldset id='vChxT'></fieldset></dl></div>
                            <tbody id='vChxT'></tbody>

                            主站蜘蛛池模板: 手术室净化厂家_成都实验室装修公司_无尘车间施工单位_洁净室工程建设团队-四川华锐16年行业经验 | 全自动包装机_灌装机生产厂家-迈驰包装设备有限公司 | 翅片管散热器价格_钢制暖气片报价_钢制板式散热器厂家「河北冀春暖气片有限公司」 | 山东锐智科电检测仪器有限公司_超声波测厚仪,涂层测厚仪,里氏硬度计,电火花检漏仪,地下管线探测仪 | 智成电子深圳tdk一级代理-提供TDK电容电感贴片蜂鸣器磁芯lambda电源代理经销,TDK代理商有哪些TDK一级代理商排名查询。-深圳tdk一级代理 | 服务器之家 - 专注于服务器技术及软件下载分享 | 内窥镜-工业内窥镜厂家【上海修远仪器仪表有限公司】 | 冲锋衣滑雪服厂家-冲锋衣定制工厂-滑雪服加工厂-广东睿牛户外(S-GERT) | 紫外荧光硫分析仪-硫含量分析仪-红外光度测定仪-泰州美旭仪器 | 产业规划_产业园区规划-产业投资选址及规划招商托管一体化服务商-中机院产业园区规划网 | 车件|铜件|车削件|车床加工|五金冲压件-PIN针,精密车件定制专业厂商【东莞品晔】 | 海峰资讯 - 专注装饰公司营销型网站建设和网络营销培训 | 咖啡加盟-咖啡店加盟-咖啡西餐厅加盟-塞纳左岸咖啡西餐厅官网 | 安规电容|薄膜电容|陶瓷电容|智旭JEC安规电容厂家 | 高铝轻质保温砖_刚玉莫来石砖厂家_轻质耐火砖价格 | 海水晶,海水素,海水晶价格-潍坊滨海经济开发区强隆海水晶厂 | 衡阳耐适防护科技有限公司——威仕盾焊接防护用品官网/焊工手套/焊接防护服/皮革防护手套 | 风化石头制砂机_方解石制砂机_瓷砖石子制砂机_华盛铭厂家 | 创富网-B2B网站|供求信息网|b2b平台|专业电子商务网站 | 不锈钢复合板厂家_钛钢复合板批发_铜铝复合板供应-威海泓方金属复合材料股份有限公司 | 卧涛科技有限公司科技项目申报公司|高新技术企业申报|专利申请 | 耐高温硅酸铝板-硅酸铝棉保温施工|亿欧建设工程 | 锻造液压机,粉末冶金,拉伸,坩埚成型液压机定制生产厂家-山东威力重工官方网站 | 跨境物流_美国卡派_中大件运输_尾程派送_海外仓一件代发 - 广州环至美供应链平台 | 新疆十佳旅行社_新疆旅游报价_新疆自驾跟团游-新疆中西部国际旅行社 | 北京租车公司_汽车/客车/班车/大巴车租赁_商务会议/展会用车/旅游大巴出租_北京桐顺创业租车公司 | 双吸泵,双吸泵厂家,OS双吸泵-山东博二泵业有限公司 | 鑫铭东办公家具一站式定制采购-深圳办公家具厂家直销 | 杭州代理记账多少钱-注册公司代办-公司注销流程及费用-杭州福道财务管理咨询有限公司 | 【化妆品备案】进口化妆品备案流程-深圳美尚美化妆品有限公司 | pbootcms网站模板|织梦模板|网站源码|jquery建站特效-html5模板网 | 北京环球北美考试院【官方网站】|北京托福培训班|北京托福培训 | 龙门加工中心-数控龙门加工中心厂家价格-山东海特数控机床有限公司_龙门加工中心-数控龙门加工中心厂家价格-山东海特数控机床有限公司 | 换网器_自动换网器_液压换网器--郑州海科熔体泵有限公司 | 净化车间_洁净厂房_净化公司_净化厂房_无尘室工程_洁净工程装修|改造|施工-深圳净化公司 | 2-羟基泽兰内酯-乙酰蒲公英萜醇-甘草查尔酮A-上海纯优生物科技有限公司 | 石英砂矿石色选机_履带辣椒色选机_X光异物检测机-合肥幼狮光电科技 | 六维力传感器_六分量力传感器_模腔压力传感器-南京数智微传感科技有限公司 | 科箭WMS仓库管理软件-TMS物流管理系统-科箭SaaS云服务 | 动库网动库商城-体育用品专卖店:羽毛球,乒乓球拍,网球,户外装备,运动鞋,运动包,运动服饰专卖店-正品运动品网上商城动库商城网 - 动库商城 | 重庆轻质隔墙板-重庆安吉升科技有限公司 |