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

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

          <bdo id='8CoHx'></bdo><ul id='8CoHx'></ul>

        <legend id='8CoHx'><style id='8CoHx'><dir id='8CoHx'><q id='8CoHx'></q></dir></style></legend>

      1. <small id='8CoHx'></small><noframes id='8CoHx'>

        使用 Leaflet-react 時(shí)如何調(diào)用 fitBounds()?

        How do you call fitBounds() when using leaflet-react?(使用 Leaflet-react 時(shí)如何調(diào)用 fitBounds()?)

        <small id='3KEEG'></small><noframes id='3KEEG'>

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

              • <bdo id='3KEEG'></bdo><ul id='3KEEG'></ul>
                <tfoot id='3KEEG'></tfoot>

                    <tbody id='3KEEG'></tbody>
                • 本文介紹了使用 Leaflet-react 時(shí)如何調(diào)用 fitBounds()?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  我不知道如何在 Leaflet 地圖上調(diào)用 fitBounds().

                  如果我只是使用香草傳單,此解決方案將完美運(yùn)行:縮放以適應(yīng) Mapbox 或 Leaflet 中的所有標(biāo)記

                  不幸的是,我正在使用 react-leaflet.

                  如果我只是單獨(dú)使用傳單,這就是解決方案.

                  var leafletMap = new L.featureGroup([marker1, marker2, marker3]);map.fitBounds(leafletMap.getBounds());

                  我認(rèn)為這段代碼(我的代碼) this.mapRef.current.leafletElement 相當(dāng)于 var leafletMap = new L.featureGroup([marker1, marker2, marker3]);leafletMap.getBounds();,但是 map.fitBounds(); 相當(dāng)于 react-leaflet 中的什么?

                  基本上,我試圖在地圖上顯示多個(gè)標(biāo)記并相應(yīng)地調(diào)整視圖(放大、縮小、飛到等).

                  這是我的代碼.

                  import React, { createRef, Component } from 'react'從 'react-leaflet' 導(dǎo)入 { Map, TileLayer, Marker, Popup, FeatureGroup }導(dǎo)出默認(rèn)類 MasterLeafletMap 擴(kuò)展組件 {構(gòu)造函數(shù)(道具){超級(jí)(道具);this.markers = this.markers.bind(this);this.handleClick = this.handleClick.bind(this);this.mapRef = createRef()}手柄點(diǎn)擊(){常量 leafletMap = this.mapRef.current.leafletElement;this.mapRef.current.fitBounds(leafletMap.getBounds());//不起作用LeafletMap.fitBounds(leafletMap.getBounds());//不起作用(只是試圖獲取標(biāo)記的邊界并調(diào)整視圖)this.mapRef.current.leafletElement.flyToBounds(leafletMap.getBounds());//不起作用}標(biāo)記(){if (this.props.search.items instanceof Array) {返回 this.props.search.items.map(function(object, i) {常量位置 = [object._geoloc.lat, object._geoloc.lng];返回<標(biāo)記位置={位置}><彈出窗口><跨度><h4>{object.title}</h4>{object.address}, <br/>{object.city}、{object.state}、{object.zip} <br/>{object._geoloc.lat},{object._geoloc.lng}</span></彈出窗口></標(biāo)記>})}}使成為() {const hasLoaded = this.props.search.items instanceof Array;如果(!已加載){返回空值;}常量位置 = [this.props.search.items[0]._geoloc.lat, this.props.search.items[0]._geoloc.lng];返回 (<div className="leaflet-map-container"><div onClick={this.handleClick}>你好</div><地圖中心={位置} zoom={13} ref={this.mapRef}>

                  提前致謝.

                  解決方案

                  這是一個(gè)如何通過 完成的示例react-leaflet

                  handleClick() {常量映射 = this.mapRef.current.leafletElement;//獲取本地地圖實(shí)例常量組 = this.groupRef.current.leafletElement;//獲取本機(jī)featureGroup實(shí)例map.fitBounds(group.getBounds());}

                  在哪里

                  <button onClick={this.handleClick}>縮放</button><地圖中心={this.props.center}縮放={this.props.zoom}參考={this.mapRef}>

                  對(duì)應(yīng)于

                  var leafletMap = new L.featureGroup([marker1, marker2, marker3]);map.fitBounds(leafletMap.getBounds());

                  這是一個(gè)演示

                  I cannot figure out how to call fitBounds() on the Leaflet map.

                  If I was just using vanilla leaflet, this solution would work perfectly: Zoom to fit all markers in Mapbox or Leaflet

                  Unfortunately, I am using react-leaflet.

                  Here is the solution if I was just using leaflet by itself.

                  var leafletMap = new L.featureGroup([marker1, marker2, marker3]);
                  map.fitBounds(leafletMap.getBounds());
                  

                  I think this code (my code) this.mapRef.current.leafletElement is equivalent to var leafletMap = new L.featureGroup([marker1, marker2, marker3]); leafletMap.getBounds();, but what is map.fitBounds(); equivalent to in react-leaflet?

                  Basically, I am trying to display multiple markers on the map and have the view adjust accordingly (zoom in, zoom out, fly to, etc.).

                  Here is my code.

                  import React, { createRef, Component } from 'react'
                  import { Map, TileLayer, Marker, Popup, FeatureGroup } from 'react-leaflet'
                  
                  export default class MasterLeafletMap extends Component {
                    constructor(props) {
                      super(props);
                      this.markers = this.markers.bind(this);
                      this.handleClick = this.handleClick.bind(this);
                      this.mapRef = createRef()
                    }
                  
                    handleClick() {
                      const leafletMap = this.mapRef.current.leafletElement;
                      this.mapRef.current.fitBounds(leafletMap.getBounds()); // Doesn't work
                      leafletMap.fitBounds(leafletMap.getBounds()); // Doesn't work (just trying to get the bounds of the markers that are there and adjust the view)
                      this.mapRef.current.leafletElement.flyToBounds(leafletMap.getBounds()); // Doesn't work
                    }
                    markers() {
                      if (this.props.search.items instanceof Array) {
                        return this.props.search.items.map(function(object, i) {
                          const position = [object._geoloc.lat, object._geoloc.lng];
                          return <Marker position={position}>
                            <Popup>
                              <span>
                                <h4>{object.title}</h4>
                                {object.address}, <br /> {object.city}, {object.state}, {object.zip} <br /> {object._geoloc.lat}, {object._geoloc.lng}
                              </span>
                            </Popup>
                          </Marker>
                        })
                      }
                  
                    }
                    render() {
                      const hasLoaded = this.props.search.items instanceof Array;
                      if (!hasLoaded) {
                        return null;
                      }
                  
                      const position = [this.props.search.items[0]._geoloc.lat, this.props.search.items[0]._geoloc.lng];
                  
                      return (
                        <div className="leaflet-map-container">
                          <div onClick={this.handleClick}>Hello</div>
                          <Map center={position} zoom={13} ref={this.mapRef}>
                            <TileLayer
                              attribution="&amp;copy <a href=&quot;http://osm.org/copyright&quot;>OpenStreetMap</a> contributors"
                              url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
                            />
                            <FeatureGroup>
                              {this.markers()}
                            </FeatureGroup>
                          </Map>
                        </div>
                      )
                    }
                  }
                  

                  Thanks in advance.

                  解決方案

                  Here is an example how to accomplish it via react-leaflet

                  handleClick() {
                      const map = this.mapRef.current.leafletElement;  //get native Map instance
                      const group = this.groupRef.current.leafletElement; //get native featureGroup instance
                      map.fitBounds(group.getBounds());
                  }
                  

                  where

                  <div>
                      <button onClick={this.handleClick}>Zoom</button>
                      <Map
                        center={this.props.center}
                        zoom={this.props.zoom}
                        ref={this.mapRef}
                      >
                        <TileLayer
                          attribution='&amp;copy <a >OpenStreetMap</a> contributors'
                          url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
                        />
                        <FeatureGroup ref={this.groupRef}>
                          {this.props.locations.map(location => (
                            <Marker
                              key={location.name}
                              position={{ lat: location.lat, lng: location.lng }}
                            >
                              <Popup>
                                <span>
                                  <h4>{location.name}</h4>
                                </span>
                              </Popup>
                            </Marker>
                          ))}
                        </FeatureGroup>
                      </Map>
                   </div>
                  

                  which corresponds to

                  var leafletMap = new L.featureGroup([marker1, marker2, marker3]);
                  map.fitBounds(leafletMap.getBounds());
                  

                  Here is a demo

                  這篇關(guān)于使用 Leaflet-react 時(shí)如何調(diào)用 fitBounds()?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

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

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

                        1. <small id='0oQM8'></small><noframes id='0oQM8'>

                            <tbody id='0oQM8'></tbody>

                            主站蜘蛛池模板: 久久国产精品一区二区三区 | 激情六月丁香婷婷 | 久草网址 | 91精品国产综合久久国产大片 | 亚洲欧美日韩精品久久亚洲区 | 亚洲国产成人精品女人久久久 | 欧美色偷拍 | 日韩精品一区二区三区视频播放 | 国产日韩欧美在线 | 国产精品黄色 | 日韩精品中文字幕在线 | 日韩三级在线观看 | 久久精品国产免费一区二区三区 | 国产91成人| 一级免费在线视频 | 中文字幕乱码视频32 | 亚洲欧美一区二区三区视频 | 亚洲首页| 色资源在线 | 欧美成人不卡 | 国产伦精品一区二区三区高清 | 亚洲免费精品 | 日本免费在线 | 久久久久久成人 | 欧美中文一区 | 国产精品一区二区免费看 | 亚洲 中文 欧美 日韩 在线观看 | 久久久久久久久淑女av国产精品 | 国产一区二区中文字幕 | 四虎影院新网址 | av大片在线观看 | www.97国产| 亚洲精品乱码 | av片在线观看网站 | 香蕉久久a毛片 | 日日操夜夜操天天操 | 久久亚洲欧美日韩精品专区 | 99久久视频 | 日韩一级黄色毛片 | 亚洲精品在线看 | 日韩插插 |