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

      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="ywc0iw2" 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="ywcmcik" 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="esigkka" id='bREIf'><tfoot id='bREIf'></tfoot><dl id='bREIf'><fieldset id='bREIf'></fieldset></dl></div>
                            <tbody id='bREIf'></tbody>
                          • 主站蜘蛛池模板: 底部填充胶_电子封装胶_芯片封装胶_芯片底部填充胶厂家-东莞汉思新材料 | 薄壁轴承-等截面薄壁轴承生产厂家-洛阳薄壁精密轴承有限公司 | 焊管生产线_焊管机组_轧辊模具_焊管设备_焊管设备厂家_石家庄翔昱机械 | 乳化沥青设备_改性沥青设备_沥青加温罐_德州市昊通路桥工程有限公司 | [官网]叛逆孩子管教_戒网瘾学校_全封闭问题青少年素质教育_新起点青少年特训学校 | 米顿罗计量泵(科普)——韬铭机械 | 道达尔润滑油-食品级润滑油-道达尔导热油-合成导热油,深圳道达尔代理商合-深圳浩方正大官网 | 运动木地板_体育木地板_篮球馆木地板_舞台木地板-实木运动地板厂家 | 知名电动蝶阀,电动球阀,气动蝶阀,气动球阀生产厂家|价格透明-【固菲阀门官网】 | 药品仓库用除湿机-变电站用防爆空调-油漆房用防爆空调-杭州特奥环保科技有限公司 | 充气膜专家-气膜馆-PTFE膜结构-ETFE膜结构-商业街膜结构-奥克金鼎 | 酒精检测棒,数显温湿度计,酒安酒精测试仪,酒精检测仪,呼气式酒精检测仪-郑州欧诺仪器有限公司 | 3d打印服务,3d打印汽车,三维扫描,硅胶复模,手板,快速模具,深圳市精速三维打印科技有限公司 | 溶氧传感器-pH传感器|哈美顿(hamilton) | 耐磨陶瓷管道_除渣器厂家-淄博浩瀚陶瓷科技有限公司 | 注塑模具_塑料模具_塑胶模具_范仕达【官网】_东莞模具设计与制造加工厂家 | 传爱自考网_传爱自学考试网| 特材真空腔体_哈氏合金/镍基合金/纯镍腔体-无锡国德机械制造有限公司 | 天空彩票天下彩,天空彩天空彩票免费资料,天空彩票与你同行开奖,天下彩正版资料大全 | 进口便携式天平,外校_十万分之一分析天平,奥豪斯工业台秤,V2000防水秤-重庆珂偌德科技有限公司(www.crdkj.com) | Magnescale探规,Magnescale磁栅尺,Magnescale传感器,Magnescale测厚仪,Mitutoyo光栅尺,笔式位移传感器-苏州连达精密量仪有限公司 | 涿州网站建设_网站设计_网站制作_做网站_固安良言多米网络公司 | 工业PH计|工业ph酸度计|在线PH计价格-合肥卓尔仪器仪表有限公司 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 网优资讯-为循环资源、大宗商品、工业服务提供资讯与行情分析的数据服务平台 | 二氧化碳/活性炭投加系统,次氯酸钠发生器,紫外线消毒设备|广州新奥 | 运动木地板厂家,篮球场木地板品牌,体育场馆木地板安装 - 欧氏运动地板 | 换链神器官网-友情链接交换、购买交易于一体的站长平台 | 自动部分收集器,进口无油隔膜真空泵,SPME固相微萃取头-上海楚定分析仪器有限公司 | 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 德州网站开发定制-小程序开发制作-APP软件开发-「两山开发」 | 发电机价格|发电机组价格|柴油发电机价格|柴油发电机组价格网 | 深圳宣传片制作_产品视频制作_深圳3D动画制作公司_深圳短视频拍摄-深圳市西典映画传媒有限公司 | CXB船用变压器-JCZ系列制动器-HH101船用铜质开关-上海永上船舶电器厂 | 工业硝酸钠,硝酸钠厂家-淄博「文海工贸」 | 双能x射线骨密度检测仪_dxa骨密度仪_双能x线骨密度仪_品牌厂家【品源医疗】 | 自恢复保险丝_贴片保险丝_力特保险丝_Littelfuse_可恢复保险丝供应商-秦晋电子 | 移动厕所租赁|移动卫生间|上海移动厕所租赁-家瑞租赁 | 水平垂直燃烧试验仪-灼热丝试验仪-漏电起痕试验仪-针焰试验仪-塑料材料燃烧检测设备-IP防水试验机 | 禹城彩钢厂_钢结构板房_彩钢复合板-禹城泰瑞彩钢复合板加工厂 | 莱州网络公司|莱州网站建设|莱州网站优化|莱州阿里巴巴-莱州唯佳网络科技有限公司 | 超声波分散机-均质机-萃取仪-超声波涂料分散设备-杭州精浩 |