I'm looking for an approach to extend Leaflet Views so that I can customise map icons for content based on a field criteria. My current use case is listing a number of venues on a map and using a different icon for each venue based on a taxonomy term field.
Approaches I'm currently looking at:
- Custom formatter for the geofield field in the content type.
- Rewriting the geodata field in the Views UI interface (Not sure if this will work given the Leaflet Views Plugin)
Any other ideas for an approach?
I'm going to take a closer look at the code in the leaflet_views_plugin_style class to start with and update this issue with what I find. Any input would be appreciated.
Comments
Comment #1
gollyg commentedOverriding the render method of that class, and adding the following code, will allow you to place custom markers:
Obviously, needs to be wrapped in conditional logic based upon a variable in the $result variable.
Comment #2
masher commentedThe IP Geolocation Views and Maps module gives you different icon types. You can designate any one field as a location differentiator.
http://drupal.org/project/ip_geoloc
Comment #3
cossovich commentedThanks @gollyg.
I ran into some problems extending the leaflet_views_plugin_style class but I did get a proof of concept working after hacking on the leaflet_views module. Attached is a patch with the hack (I don't recommend using this patch; it's hard-coded to custom fields and includes multiple crimes against Drupal), I've only included it here to demonstrate what I'm trying to achieve.
@masher, I'm going to look at the IP Geolocation Views and Maps views plugins to see their approach.
Comment #4
gollyg commentedThat seems to me the correct approach, but applied to a plugin that extends this plugin. Could you get view to recognise your plugin?
Comment #5
cossovich commented@gollyg PHP ran out of memory when I enabled (or disabled) the module with my views style plugin. I'm going to move forward with the hack and do some more research into how I might extend the Leaflet views plugin.
Comment #6
revagomes commentedI think this is a good way to achieve this goal. Feel free to improve if needed.
Comment #7
osopolarWhat about using tokens? See #1918170: Use tokens in icon url.
Comment #8
gcbLooks like this is duplicating functionality offered by #1812748, #1882806 and some others. Thanks for the work, look for one of these solutions to be rolled into a release upcoming soon.
Comment #9
antims commentedHow to use replace pattren in leaflet views for icon field ?