react-leaflet icon indicating copy to clipboard operation
react-leaflet copied to clipboard

marker Icon not showing

Open anujsinghwd opened this issue 8 years ago • 5 comments

Map is loading corrrectly but marker icon is not showing

<Map center={position} zoom={this.state.zoom}>
        <TileLayer
                    url={url}
                    attribution="&amp;copy <a href=&quot;http://www.mapmyindia.com/about/privacy-policy&quot;>MapMyIndia</a> contributors"
                />
         <Marker position={position}>
             <Popup>A pretty CSS3 popup.<br />Easily customizable.</Popup>
       </Marker>
  </Map>

Error:

Failed to load resource: net::ERR_INVALID_URL

anujsinghwd avatar Sep 25 '18 09:09 anujsinghwd

Same here P.S. https://github.com/PaulLeCam/react-leaflet/issues/453 here's what solved my problem

phdog avatar Sep 27 '18 21:09 phdog

@phdog i found the solution use custom marker. this resolve your issue.

anujsinghwd avatar Sep 28 '18 05:09 anujsinghwd

This custom marker resolved problem for me (have to give right path for marker image): https://stackoverflow.com/questions/47723812/custom-marker-icon-with-react-leaflet

QauseenMZ avatar Mar 10 '20 23:03 QauseenMZ

I found this solution in another page:

`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;`

this work for react-leaflet

MendezBruno avatar Jan 07 '22 02:01 MendezBruno

I had a similar problem when using leaflet on a react project but the following steps worked for me:

Step 1: I removed the import "leaflet/dist/leaflet.css" line of code from my index.js document. Step 2: I copied and pasted the link below to the CSS file for leaflet from leafletjs.com and pasted it in the header section of my index.html document.

Leafletjs CSS link: ( )

Teewaii avatar Sep 14 '22 12:09 Teewaii