Is it possible to let the map icon-> icon url field to accept replacement patterns? So for instance one can put in the nodes image as a marker on the map.

Comments

FAAREIA’s picture

I'm just looking for that feature.
It would be nice to use token replacement within the Icon URL at views. Then, for example, we can create a color taxonomy vocabulary, with a custom field in which there will be an url (the image url).
Image size X and Y could be another customs fields in the taxonomy....

just a great feature could be...

thanks for all.

osopolar’s picture

Status: Active » Needs review
StatusFileSize
new2.29 KB

Adding token support for icons - not only iconURL, so icons with different size could also be used.

I am not sure if the image URL needs to be validated by the function leaflet_icon_validate() needs to be disabled too.

This does not work for views, at least not with field based displays.

andreystrelkov’s picture

Hello, I apply this patch, but REPLACEMENT PARTS in Leaflet Map Setting is absent :(

osopolar’s picture

@andreystrelkov: It's not in the Leaflet Map Settings, its in the field formatter settings (in content-type and views). I.e.: http://example.com/admin/structure/types/manage/{content-type}/display >> click on the gears icon and you will see the settings. At the end of the form is a tiny link to show all tokens.

I am not sure, if a path with token will be always valid. Maybe the validation callback needs to be adjusted for token use. The validation should only used for path with out token, because the token value is not known on form validation.

andreystrelkov’s picture

StatusFileSize
new55.98 KB

Hmmm :(
And there are any chances that the tokens (replacement parts) were converted to links here?

screen

osopolar’s picture

StatusFileSize
new46.63 KB

You need to scroll down a bit more. You can also use tokens for the other icon settings like Icon Size etc.

Leaflet_-_Token_support_for_Icons.png

andreystrelkov’s picture

amazingly :(... I have this missing link. Maybe I applied the patch in the wrong way. Can You give your already patched leaflet.formatters.inc file, and please tell me another version of the module you.

osopolar’s picture

I use leaflet version 7.x-1.0-beta3

0. Download current (stable) version of leaflet.
1. Change Directory to the leaflet module (i.e. cd sites/all/modules/contrib/leaflet)
2. run: patch --dry-run -p1 < path-to-the-patchfile/leaflet-image-url-token-1918170-2.patch
3. if above command runs without errors run patch -p1 < path-to-the-patchfile/leaflet-image-url-token-1918170-2.patch ... if ther are errors pleas post here.
4. clear all your caches (ie. druch cc all)

More information about applying patches you will find under https://drupal.org/patch/apply

I hope this helps. Let me know here, if this works for you.

andreystrelkov’s picture

Thanks a lot for that answer! It turns out I'm stupid, I tried to find in the display settings, and it turns out they are in the settings of the field with coordinates.

But here's the rub, your line into tokens only appears when you select a format Leaflet, but I have with this formatter my map is not displayed, and displayed only when the format longitude and latitude, which has no links to the tokens.

Can I have something mixed up?

osopolar’s picture

Yes, this is for leaflet maps only.

Check the console log for 404 errors on our marker image and the source code, if the marker image is there as expected (it should be in a json sting, somewhere in a js drupal settings variable).

2pha’s picture

Please take a look at the patch I have added over at https://drupal.org/node/2089209
It adds advanced map settings and token support for the marker url (same as here), but also adds it to leaflet_views too.

gcb’s picture

Issue summary: View changes
Status: Needs review » Fixed

Great idea, thanks. It appears to be showing up in lots of patches, I've added this for all configuration fields on views & view modes.

gcb’s picture

Status: Fixed » Closed (fixed)
Pete B’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.62 KB

Thanks for the work here! It's great. There is one problem though.

Tokens don't work on leaflet_views unless you use the formatted entity in the description. Otherwise $entity is not available and the tokens get replaced with nothing.

I have added an option so we can use tokens in views.

mrpeanut’s picture

For what it's worth, the patch in #14 applied cleanly and works great for me.

peter van den heuvel’s picture

For me patch #14 worked also.

Getting a little offset in the markers though. Suspect a CSS-problem, but nothing that can be solved. Are there any plans for this patch getting it in the leaflet-module?

EDIT: used offset-marker settings.

andreystrelkov’s picture

Also #14 work, but only TOKEN, replacement pattern didn't... sadly

milos.kroulik’s picture

Title: Replacement patterns in icon url » Use tokens in icon url
Status: Needs review » Reviewed & tested by the community

I can also confirm, that patch in #14 works. Can this be switched to RTBC?

joelstein’s picture

Patch #14 works for me, if I use a token. Thanks!

robertwb’s picture

I am looking at this and the related #11, and wondering if the existing "html DivIcon" capability already accounts for this? However, I can not find any example documentation for employing DivIcon. If anyone knows how to do a custm icon in a ReWritten field using DivIcon, please post it up here.

robertwb’s picture

Docs on DivIcon in Leaflet (not Drupal specific): http://www.coffeegnome.net/labels-in-leaflet/

rudetrue’s picture

Thanks for the patch #14. I'm using it to have different marker icons for the same content type, and it's working well.

The way the DivIcon works in this module didn't cover my use case. Also, this method is more straightforward to configure, and was the first thing I tried.

cornelyus’s picture

I applied the patch on #14, and it all works fine except that it doesn't replace tokens refering to the node, like [node:nid]. I needed the value of a field inside the node to make it possible to show different images for the icon.

I have version 1.1.

vinmassaro’s picture

Tested the patch in #14 with success.

sano’s picture

patch #14 works for me as well. thanks.