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

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

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

        結合 React 和 Leaflet 的好方法

        Good way to combine React and Leaflet(結合 React 和 Leaflet 的好方法)

          • <legend id='rWQkL'><style id='rWQkL'><dir id='rWQkL'><q id='rWQkL'></q></dir></style></legend>
            <tfoot id='rWQkL'></tfoot>
              <tbody id='rWQkL'></tbody>

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

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

                • 本文介紹了結合 React 和 Leaflet 的好方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在做一個結合 React 和 Leaflet 的項目,但我必須說我在語義方面遇到了一些困難.

                  I am working on a project to combine React and Leaflet, but I must say I am having some hard time with the semantics.

                  由于大部分東西都是由 Leaflet 直接管理的,我不知道將 Leaflet 映射實例添加為 React 組件中的狀態是否有意義.

                  As most of the stuff is managed by Leaflet directly, I don't know if it would make sense to add the Leaflet map instance as state in the React Component or not.

                  在使用 Leaflet 創建標記時遇到同樣的問題,因為它不返回任何內容,我真的沒有任何東西可以渲染.邏輯本身對我來說似乎很模糊.

                  Same problem when it comes to creating markers with Leaflet, as it does not return anything, I don't have anything to render really. The logic itself seems blurry to me.

                  這是我開始制作的.它工作正常,但我覺得我在編寫糟糕的代碼并且錯過了這個概念.

                  Here is what I started to make. It's working but I feel like I'm writing bad code and missing the concept.

                  /** @jsx React.DOM */
                  
                  /* DOING ALL THE REQUIRE */
                  var Utils = require('../core/utils.js');
                  
                  var Livemap = React.createClass({
                      uid: function() {
                          var uid = 0;
                          return function(){
                              return uid++;
                          };
                      },
                      getInitialState: function() {
                          return {
                              uid: this.uid()
                          }
                      },
                      componentDidMount: function() {
                          var map = L.map('map-' + this.state.uid, {
                              minZoom: 2,
                              maxZoom: 20,
                              layers: [L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '&copy; <a >OpenStreetMap</a> contributors, <a })],
                              attributionControl: false,
                          });
                          map.fitWorld();
                          return this.setState({
                              map: map
                          });
                      },
                      render: function() {
                          return (
                              <div className='map' id={'map-'+this.state.uid}></div>
                          );
                      }
                  });
                  
                  (function(){
                      Utils.documentReady(function(){
                          React.render(
                              <Livemap />,
                              document.body
                          )
                      });
                  })();
                  

                  所以我的問題是:

                  • 這個樣本看起來合法嗎?
                  • 您將如何處理添加標記和管理其事件的邏輯?

                  推薦答案

                  • 您不需要自己管理唯一性,即UID".相反,您可以使用 getDOMNode訪問組件的真實節點.Leaflet 的 API 支持字符串選擇器或 HTMLElement 實例.
                  • Leaflet 正在管理渲染,因此 map 不應存在于 state 上.只在 state 中存儲影響 React 渲染 DOM 元素的數據.
                    • You don't need to manage uniqueness, i.e. "UID", yourself. Instead, you can use getDOMNode to access the component's real node. Leaflet's API supports either a string selector or an HTMLElement instance.
                    • Leaflet is managing rendering, so the map should not live on state. Only store data in state that affects React's rendering of the DOM element.
                    • 除了這兩點之外,請正常使用 Leaflet API,并根據需要將 React 組件的回調綁定到 Leaflet 映射.React 在這一點上只是一個包裝器.

                      Beyond those two points, use the Leaflet API normally and tie callbacks from your React component to the Leaflet map as you like. React is simply a wrapper at this point.

                      import React from 'react';
                      import ReactDOM from 'react-dom';
                      
                      class Livemap extends React.Component {
                      
                          componentDidMount() {
                              var map = this.map = L.map(ReactDOM.findDOMNode(this), {
                                  minZoom: 2,
                                  maxZoom: 20,
                                  layers: [
                                      L.tileLayer(
                                          'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
                                          {attribution: '&copy; <a >OpenStreetMap</a> contributors, <a })
                                  ],
                                  attributionControl: false,
                              });
                      
                              map.on('click', this.onMapClick);
                              map.fitWorld();
                          }
                      
                          componentWillUnmount() {
                              this.map.off('click', this.onMapClick);
                              this.map = null;
                          }
                      
                          onMapClick = () => {
                              // Do some wonderful map things...
                          }
                      
                          render() {
                              return (
                                  <div className='map'></div>
                              );
                          }
                      
                      }
                      

                      這篇關于結合 React 和 Leaflet 的好方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 圖層控件添加到側邊欄)
                  1. <tfoot id='bREIf'></tfoot>

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

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

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

                          <i id='bREIf'><tr id='bREIf'><dt id='bREIf'><q id='bREIf'><span id='bREIf'><b id='bREIf'><form id='bREIf'><ins id='bREIf'></ins><ul id='bREIf'></ul><sub id='bREIf'></sub></form><legend id='bREIf'></legend><bdo id='bREIf'><pre id='bREIf'><center id='bREIf'></center></pre></bdo></b><th id='bREIf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='bREIf'><tfoot id='bREIf'></tfoot><dl id='bREIf'><fieldset id='bREIf'></fieldset></dl></div>
                            <tbody id='bREIf'></tbody>
                          • 主站蜘蛛池模板: 人妖videosex高潮另类 | 伦理二区| 欧美成年人 | 国产欧美日韩一区 | 丝袜美腿一区 | av在线免费观看网站 | 国产一区二区三区四区hd | 欧美成人精品 | 国产美女永久免费无遮挡 | 亚洲精品视频在线播放 | 久久精品国产一区二区 | www.日韩在线| h小视频 | 欧美日韩综合 | 国产 亚洲 网红 主播 | 日韩成人av在线播放 | 国产电影一区二区三区爱妃记 | 国产免费观看视频 | 亚洲欧美一区二区三区1000 | 国产黄色大片在线免费观看 | 日本不卡一区二区三区在线观看 | 欧美在线观看黄色 | 天堂网中文字幕在线观看 | 久久无毛 | 亚洲一区在线日韩在线深爱 | 亚洲精品视频在线观看免费 | 欧美在线一区二区三区 | 国产精品久久久久久久一区二区 | 国产高清视频一区 | 国产乱码精品1区2区3区 | 国产一区不卡在线观看 | 亚洲精品白浆高清久久久久久 | 国产精品久久久久久久久久 | 精品欧美一区二区三区久久久 | 成年人黄色小视频 | 日本精品一区二区在线观看 | 日韩成人免费中文字幕 | 亚洲精品1区 | 在线观看黄色 | 久久久国产一区二区三区四区小说 | 亚洲情侣视频 |