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

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

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

      <tfoot id='TLKq2'></tfoot>
      <legend id='TLKq2'><style id='TLKq2'><dir id='TLKq2'><q id='TLKq2'></q></dir></style></legend>
      1. 未找到 React-Leaflet 标记文件

        时间:2023-08-09
          <tfoot id='VVkLp'></tfoot>
            <bdo id='VVkLp'></bdo><ul id='VVkLp'></ul>
            <legend id='VVkLp'><style id='VVkLp'><dir id='VVkLp'><q id='VVkLp'></q></dir></style></legend>

          • <small id='VVkLp'></small><noframes id='VVkLp'>

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

                    <tbody id='VVkLp'></tbody>
                  本文介绍了未找到 React-Leaflet 标记文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有非常简单的代码来使用 react-leaflet 显示地图并在其上放置一个标记.但是,我在浏览器控制台中收到以下两个错误

                  I've got very simple code to display a map using react-leaflet and place a marker on it. However, i get the following two errors in my browser console

                  GET http://localhost:8080/marker-icon-2x.png404(未找到)

                  GET http://localhost:8080/marker-icon-2x.png 404 (Not Found)

                  GET http://localhost:8080/marker-shadow.png 404(未找到)

                  GET http://localhost:8080/marker-shadow.png 404 (Not Found)

                  我尝试通过下载这两个图像并将它们放在根目录来解决此问题.有用.但是,如何更改 react-leaflet 标记元素查找标记图像的 URL?我想将它们存储在./images"而不是根目录中.

                  I tried to fix this issue by downloading those two images and placing them at the root. It works. However, how can i change the URL the react-leaflet marker element looks for the marker images? I'd like to store them in "./images" rather than at the root.

                  推荐答案

                  试试这个:)

                  由于某种原因,React 传单不包含图像,您需要重新设置默认图标图像.

                  React leaflet for some reason do not include images and you will need to reset default icons image.

                  以下是一些工作示例,希望它能解决您的问题.

                  Below is some working example, I hope it will solve your issue.

                  您还可以从公共链接之一添加图标

                  You also can add icons from one of public link

                  https://cdnjs.com/libraries/Leaflet.awesome-markers

                  import React, { Component } from 'react';
                  import L from 'leaflet';
                  import {
                      Map, TileLayer, Marker, Popup
                  } from 'react-leaflet'
                  import 'leaflet/dist/leaflet.css';
                  import './style.css';
                  
                  
                  import icon from 'leaflet/dist/images/marker-icon.png';
                  import iconShadow from 'leaflet/dist/images/marker-shadow.png';
                  
                  let DefaultIcon = L.icon({
                      iconUrl: icon,
                      shadowUrl: iconShadow
                  });
                  
                  L.Marker.prototype.options.icon = DefaultIcon;
                  

                  这篇关于未找到 React-Leaflet 标记文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Leaflet 中获取当前地图范围内的标记/图层列表 下一篇:如何在不使用 Leaflet.draw UI 的情况下单击一个按钮

                  相关文章

                  最新文章

                • <legend id='ygssy'><style id='ygssy'><dir id='ygssy'><q id='ygssy'></q></dir></style></legend>

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

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

                    <tfoot id='ygssy'></tfoot>