-
Notifications
You must be signed in to change notification settings - Fork 70
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
Marker gone in development mode #56
Comments
Had the same problem, I solved it in my fork originally by explicitly setting the L.Icon.Default.prototype.options for the markers with the respective assets paths to the icons in the vendor/assets/javascripts/leaflet.js.erb.
Additionally I had to make sure that L.Icon.Default.imagePath returns a whitespace, not an empty string:
see my fork for full details: https://github.com/MartinHinz/leaflet-rails/tree/leaflet1.0.1 Last commit. Not sure if this will work in the current environment, but might give a clue in which direction bug fixing might be necessary... |
Hmm -- I remember testing this out specifically, and it seemed to work. Will investigate. Thanks for the reports @Bodata and @MartinHinz |
Just tested with Rails 5 and it seems to work in both development and production environments -- what version of Rails are you on @Bodata and @MartinHinz? |
Used a Rails 5 environment to test my fork. But have not tested your last version yet, I have to admit. Linux system, btw. |
I am on rails 4.2, working on windows. If i should give extra output let me know, i could test if it behaves identical on linux. |
Just tested in Rails 5 application (Ruby 2.3.1), confirm error. Same situation like I experienced before the last commit of my fork, so obviously the similar source of the error. What happens is: Url of the marker is composed like this:
Note that the marker-icon.png shows up twice in the path. It seems, there is no L.Icon.Default.imagePath set, so in L.Icon.Default._getIconUrl the image path is taken from this._detectIconPath(), and L.Icon.prototype._getIconUrl.call(this, name) is appended. Your function from leaflet.js.erb is not called, it seems. I only made it work in my fork by using the original function, and 'pretend' and imagePath as beeing a whitespace, and than setting the L.Icon.Default.prototype.options.[iconUrl, iconRetinaUrl, shadowUrl] with the assets path in leaflet.js.erb. See commit MartinHinz@eb643f0 |
Might be easier to compare working solution: @Bodata, @axyjo : Could you try my current fork of version 1.0.2: https://github.com/MartinHinz/leaflet-rails/tree/fix_icon_paths If it works for you, I might issue a pull request again. |
I will try, but have to work on other things now. |
Just to be clear, you're both including |
Hi, I had the same problem with Rails 5 on Windows.
|
Relevant part from the application.js of my application:
So it is leaflet.js, I suppose!? |
Having now proof that it works also in other environments than mine, I will make this a pull request. See #57 |
I'm still hesitant on merging in this approach -- I'd like to get to the root cause of this. I'll set up a windows installation to test it out. Until then, @MartinHinz seems like a viable approach. |
The root cause seem to be this: It seems that L.Marker's icon option is instantiated with the L.Icon.Default during initialisation:
So changing L.Icon.Default afterwards is not changing the instantiated object of the icon within Marker. The canonical way to change the icons (and their paths) is according to the documentation in leaflet-src.js (Line 6242-43):
That is what my snippet is doing essentially. Keep in mind, that it is not a windows issue, since I am using (Arch) Linux, too. |
Hi, I confirm that i do not include leaflet-src. I agree the problem is not windows only. #gem 'leaflet-rails', github: 'axyjo/leaflet-rails', ref: 'dfc8621f99d6187c051d19b31a979a75e702bd22' # does not work If i take the last working version and add the files of the next version, image and stylesheets directories can be updated.
Regards, |
I'm having the same problem on OSX.
|
I've submitted an alternative fix for this problem in #67 that simply reruns the icon initialization code of L.Marker after the overrides have been applied. It works in my use case, and I'd be interested to know if it fixes this for other people too. |
Released a new version -- 1.0.3 should fix it. |
I updated the leaflet gem from 0.7.7 to 1.0.2
In development my map markers are not found anymore.
The system does a get /assets/marker-icon-[lot of number].png%22marker-icon.png
I think it appends "%22marker-icon.png" it is a very strange filename
When i downgraded to 0.7.7 things worked ok again. When i updated to 1.0.2 markers where gone again !!
I am working on Window, perhaps this has something to do with it.
The text was updated successfully, but these errors were encountered: