久久久久久久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>
                          • 主站蜘蛛池模板: 久久手机视频 | 亚洲一区导航 | 国产欧美一区二区三区日本久久久 | 91亚洲国产 | 成人欧美一区二区三区黑人孕妇 | 91精品国产综合久久久动漫日韩 | 午夜视频网站 | 视频二区| 成人在线视频观看 | 欧美日韩综合视频 | 亚洲精品电影网在线观看 | 在线一区二区三区 | julia中文字幕久久一区二区 | 91在线视频播放 | 丝袜一区二区三区 | 春色av| 国产真实精品久久二三区 | 欧美不卡一区二区三区 | 国产在线一区二区三区 | 国产精品视频一区二区三区四区国 | 欧美色人| 国产欧美精品一区二区 | 台湾a级理论片在线观看 | 日本成人毛片 | 日韩欧美在线不卡 | 久久91| 亚洲最大看片网站 | 在线婷婷 | 亚洲精品福利视频 | 日韩欧美大片 | 亚洲九九精品 | 精久久久久 | 国产一级在线观看 | 91精品亚洲 | 欧美一区二区三区视频在线 | 中文字幕国产视频 | 欧美精品91爱爱 | 亚洲精品视频观看 | 国产精品观看 | 国产人成精品一区二区三 | 在线视频一区二区三区 |