1. <legend id='WnSSP'><style id='WnSSP'><dir id='WnSSP'><q id='WnSSP'></q></dir></style></legend>
        <bdo id='WnSSP'></bdo><ul id='WnSSP'></ul>

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

    2. <i id='WnSSP'><tr id='WnSSP'><dt id='WnSSP'><q id='WnSSP'><span id='WnSSP'><b id='WnSSP'><form id='WnSSP'><ins id='WnSSP'></ins><ul id='WnSSP'></ul><sub id='WnSSP'></sub></form><legend id='WnSSP'></legend><bdo id='WnSSP'><pre id='WnSSP'><center id='WnSSP'></center></pre></bdo></b><th id='WnSSP'></th></span></q></dt></tr></i><div id='WnSSP'><tfoot id='WnSSP'></tfoot><dl id='WnSSP'><fieldset id='WnSSP'></fieldset></dl></div>

      1. <tfoot id='WnSSP'></tfoot>

        react-leaflet 创建自定义组件

        时间:2023-08-09
          <tbody id='TFTK6'></tbody>
          <bdo id='TFTK6'></bdo><ul id='TFTK6'></ul>

          1. <tfoot id='TFTK6'></tfoot>

                <legend id='TFTK6'><style id='TFTK6'><dir id='TFTK6'><q id='TFTK6'></q></dir></style></legend>

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

                  <i id='TFTK6'><tr id='TFTK6'><dt id='TFTK6'><q id='TFTK6'><span id='TFTK6'><b id='TFTK6'><form id='TFTK6'><ins id='TFTK6'></ins><ul id='TFTK6'></ul><sub id='TFTK6'></sub></form><legend id='TFTK6'></legend><bdo id='TFTK6'><pre id='TFTK6'><center id='TFTK6'></center></pre></bdo></b><th id='TFTK6'></th></span></q></dt></tr></i><div id='TFTK6'><tfoot id='TFTK6'></tfoot><dl id='TFTK6'><fieldset id='TFTK6'></fieldset></dl></div>
                  本文介绍了react-leaflet 创建自定义组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想创建一个带有显示鼠标实际位置 (x,y) 的 react-leaflet 的自定义组件,但我不知道如何创建它.我找到了 react-leaflet-control 但它似乎不是最新的,当然我阅读了 api 文档 https://react-leaflet.js.org/docs/en/custom-components.html 但我不明白:/

                  I would like to create a custom component with react-leaflet that shows the actual position (x,y) of the mouse, but I don't know how to create it. I found react-leaflet-control but it seems that it is not up to date, of course I readded the api documentation https://react-leaflet.js.org/docs/en/custom-components.html but I did not understand it :/

                  谁能给我一个自定义组件的例子,只要一个显示Hello world"的组件就足够了.

                  Can someone give me an exemple of a custom component please, juste a component that display "Hello world" whould be more than enought.

                  推荐答案

                  根据 文档,创建一个自定义组件需要以下步骤:

                  As per documentation, to create a custom component the following steps are required:

                  1)扩展React-Leaflet提供的抽象类之一,例如:

                  1)extend one of the abstract classes provided by React-Leaflet, for example:

                  class MapInfo extends MapControl {
                     //...
                  } 
                  

                  2)实现createLeafletElement(props:Object):Object方法创建相关Leaflet元素实例,例如:

                  2)implement createLeafletElement (props: Object): Object method to create the relevant Leaflet element instance, for example:

                  createLeafletElement(opts) {
                      const MapInfo = L.Control.extend({
                        onAdd: (map) => {
                          this.panelDiv = L.DomUtil.create('div', 'info');
                          return this.panelDiv;
                        }
                      });
                      return new MapInfo({ position: 'bottomleft' });
                  }
                  

                  3) 使用 withLeaflet() HOC 包装您的自定义组件,例如:

                  3) wrap your custom component using the withLeaflet() HOC, for example:

                  export default withLeaflet(MapInfo);
                  

                  下面的例子演示了如何创建一个自定义组件来显示鼠标在地图上的实际位置(lat,lng):

                  The following example demonstrates how create a custom component to display the actual position (lat,lng) of the mouse on map:

                  演示

                  这篇关于react-leaflet 创建自定义组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将现有的传单多边形添加到现有的传单图层 下一篇:如何将两个 geoJSON 特征集合添加到两个图层组中

                  相关文章

                  最新文章

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

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

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

                    1. <tfoot id='3WnnP'></tfoot>
                        <bdo id='3WnnP'></bdo><ul id='3WnnP'></ul>