Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L.Icon.Default.imagePath should be relative to leaflet-map.html but is relative to root document #15

Open
atdotslashdot opened this issue Jan 22, 2015 · 8 comments

Comments

@atdotslashdot
Copy link

Hi, the demos with markers are not working unless I have the leaflet folder in the root of my site.
After a bower install (where the leaflet folder is installed in the bower_component folder at the same level as leaflet-map)
I'm getting a 404 not found
http://mysite.com/leaflet/dist/images/marker-icon.png
and another 404 for marker-shadow.png

@nhnb nhnb changed the title default marker location should be relative? L.Icon.Default.imagePath should be relative to leaflet-map.html but is relative to root document May 24, 2015
@nhnb
Copy link
Contributor

nhnb commented May 24, 2015

L.Icon.Default.imagePath is set to "../leaflet/dist/images". So in a typical bower based environment that is the correct path; relative to leaflet-map.html. Unfortunately the path is not interpreted relatively to leaflet-map.html, but to the root document, which hosts <leaflet-map>.

I guess it is likely to work in more scenarios, if I set it to /bower_components/leaflet/dist/images. But that still is no real solution.

@nhnb
Copy link
Contributor

nhnb commented May 31, 2015

This issue was fixed in 1.0

@nhnb nhnb closed this as completed May 31, 2015
@kingflurkel
Copy link

Nope, still have this issue.

@nhnb
Copy link
Contributor

nhnb commented Jul 2, 2015

@kingflurkel do you have a <link>-tag to import leaflet-map.html in the main document?

@nhnb nhnb reopened this Jul 2, 2015
@jpizarrom
Copy link

Maybe it's better to have a config param in leaflet-map
see the pull request #36

                      /**
              * If set, set icon default imagepath
              *
              * @attribute icon-default-image-path
              * @type string
              * @default null
              */
             iconDefaultImagePath: {
                type: String,
                value: null,
             }

@jpizarrom
Copy link

the iconDefaultImagePath param strategy will work with vulcanized files

@phaux
Copy link

phaux commented Aug 10, 2016

The leaflet lib is looking for the script tag of itself to find the correct path so I fixed it by adding the following to the main index.html.

<script src="/bower_components/leaflet/dist/leaflet.js"></script>

@tonimc
Copy link
Contributor

tonimc commented Jan 19, 2017

I create this pull request #84 in which you don't need to use the <link>-tag of leaflet-map.html in the main document neither use a workaround importing directly the leaflet js library.

It gets the URL of the component and with it build the default icon URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants