久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

      1. <legend id='BGpAd'><style id='BGpAd'><dir id='BGpAd'><q id='BGpAd'></q></dir></style></legend>
      2. 使用傳單 API 更新標(biāo)記位置

        update marker location with leaflet API(使用傳單 API 更新標(biāo)記位置)

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

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

                    <tbody id='ZfJ74'></tbody>

                • 本文介紹了使用傳單 API 更新標(biāo)記位置的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我想使用 Leaflet API 構(gòu)建 Web 應(yīng)用程序.首先,我的用戶使用 IP 進(jìn)行地理定位,然后如果他接受,我嘗試使用 HTML5 地理定位更新他的位置(準(zhǔn)確性更好).

                  I want to build web app with the Leaflet API. First my user is geolocated with IP then if he accepts I try to update his position with HTML5 geolocation (accuracy is better).

                  我的問(wèn)題是地圖上的標(biāo)記位置未更新,并且下面的代碼失敗且沒(méi)有錯(cuò)誤.我從 leaflet 文檔 嘗試了數(shù)百種不同的語(yǔ)法和方法來(lái)更新標(biāo)記位置(即 setLatLng),但我沒(méi)有成功.我想了解我的代碼有什么問(wèn)題.

                  My problem is that the marker position is not updated on the map and the code bellow fails with no error. I have try hundred of different syntax and methods from leaflet documentation to update marker position (ie. setLatLng) but I did not succeed. I would like to understand what's wrong with my code.

                  我的問(wèn)題通過(guò)這樣做解決了:

                  My problem is solved by doing like this :

                      var lat = (e.latlng.lat);
                      var lng = (e.latlng.lng);
                      var newLatLng = new L.LatLng(lat, lng);
                      marker.setLatLng(newLatLng); 
                  

                  舊代碼是:

                  //initial IP based geolocation
                  
                  var lat = google.loader.ClientLocation.latitude;
                  var lng = google.loader.ClientLocation.longitude;
                  
                  //place marker on the map
                  
                  var marker = L.marker([lat,lng]).addTo(map);
                  
                  //start HTML5 geolocation 
                  
                  map.locate({setView: true, maxZoom: 16});
                  
                  function onLocationFound(e) {
                  
                      var marker = L.marker([e.latlng.lat,e.latlng.lng]).update(marker);
                      alert ('New latitude is ' + e.latlng.lat)
                  }
                  
                  map.on('locationfound', onLocationFound);
                  

                  推薦答案

                  你的問(wèn)題里面的代碼有點(diǎn)混亂,你只貼片段很難說(shuō)是什么問(wèn)題.

                  The code inside your question is a little bit confusing, it's hard to say what the issue is when you only post snippets.

                  事實(shí)上,這段代碼:

                      var lat = (e.latlng.lat);
                      var lng = (e.latlng.lng);
                      var newLatLng = new L.LatLng(lat, lng);
                      marker.setLatLng(newLatLng); 
                  

                  ..應(yīng)該在 onLocationFound() 中按預(yù)期工作.

                  ..should work as expected inside onLocationFound().

                  你可以簡(jiǎn)化它:

                  marker.setLatLng(e.latlng);
                  

                  但是,我想問(wèn)題是范圍問(wèn)題,您的某些變量(例如標(biāo)記)在 onLocationFound 中無(wú)法訪問(wèn).

                  However, I guess the problem is a scope-issue, some of your variables (e.g. marker) is not accessible inside onLocationFound.

                  這里是一個(gè)如何實(shí)現(xiàn)的例子:

                  Here an example how to achieve it:

                  function init(){
                      var map             = L.map('map', {center: [51.505, -0.09], zoom: 13}),
                          marker          = L.marker(map.getCenter()).addTo(map),
                          glcl            = google.loader.ClientLocation,
                          onLocationfound = function(e){
                            marker.setLatLng(e.latlng);
                            map.setView(marker.getLatLng(),map.getZoom()); 
                            alert('Marker has been set to position :'+marker.getLatLng().toString());
                          };
                  
                      L.tileLayer('http://{s}.tile.cloudmade.com/[yourCloudmadeKey]/997/256/{z}/{x}/{y}.png').addTo(map);
                  
                      map.on('locationfound', onLocationfound);
                  
                      if(glcl){//when google.loader.ClientLocation contains result
                         onLocationfound({latlng:[glcl.latitude,glcl.longitude]});
                      }else{alert('google.loader.ClientLocation fails');}
                  
                      map.locate();
                  } 
                  

                  演示:http://jsfiddle.net/doktormolle/6ftGz/

                  這篇關(guān)于使用傳單 API 更新標(biāo)記位置的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

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

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

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

                          <tbody id='pnFYr'></tbody>
                        <legend id='pnFYr'><style id='pnFYr'><dir id='pnFYr'><q id='pnFYr'></q></dir></style></legend>

                          <bdo id='pnFYr'></bdo><ul id='pnFYr'></ul>

                          1. <tfoot id='pnFYr'></tfoot>
                            主站蜘蛛池模板: 国产不卡一 | 欧美日韩在线精品 | 久久91精品国产 | 国产日韩一区二区三免费高清 | av网站在线免费观看 | 精品区一区二区 | 91亚洲国产成人久久精品网站 | 中文字幕在线精品 | 成人精品鲁一区一区二区 | 亚洲欧美一区二区三区国产精品 | 久久亚洲视频 | 看片一区| 国产午夜精品久久 | 亚洲精品aⅴ | www.色53色.com | 天天爱av | 欧美日韩精选 | 亚洲精品 在线播放 | 欧美成人免费在线视频 | 日本亚洲精品成人欧美一区 | 欧美一级淫片免费视频黄 | 欧美成人精品一区二区男人看 | www国产成人 | 欧美一区二区三区在线看 | 国产四区| 欧美综合在线观看 | 亚洲精品国产电影 | 久久国产一区二区 | 精品国产一区二区三区免费 | 一级片在线免费播放 | 精品久久久久久久久久久下田 | 日韩精品一区二 | 最新av在线播放 | 欧美午夜影院 | 91精品国产高清一区二区三区 | 亚洲免费视频一区 | 国产激情偷乱视频一区二区三区 | 精品视频一区二区三区在线观看 | 亚洲一区二区三区在线视频 | 中文字幕精品一区二区三区精品 | 亚洲久久 |