Allow different icons
dixon_ - April 20, 2009 - 23:42
| Project: | Mapstraction |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
With this patch we allow each node/marker to have different and custom icons.
To test:
- Add a CCK text field to a node type that appears in your map.
- Enter a URL to your custom icon in this node field.
- Map the field with the "Icon URL" field in the Mapstraction view style options.
- Find the custom icon on your map :)
I'd suggest that we commit #437644: Set initial point dynamically first, then re-roll this patch to work with dev. We also have to change the element descriptions to document this function better. But that can go in a later patch...
| Attachment | Size |
|---|---|
| icons.patch | 1.67 KB |

#1
Rerolled this patch after committing #437644: Set initial point dynamically. Still needs to fix element descriptions.
#2
Tested successfully, so committing the patch from #1. But I mark this as still needs work because we need to change the element descriptions for this functions to be documented correctly.
#3
This works for me. I am using it based off of values on dropdowns so I have to override the view field for that content field and return the image path, but it works.
#4
I have setup a view with an argument to sort out map locations. If I bypass the argument with "all", I get my custom icons. However, if I use an argument I only get icon shadows on the map and no icons. The view without arguments at all will give custom icons.
I tried to look it over some, but only knowing enough javascript to be dangerous, i had no luck. I have checked in mapstraction.js and in Marker.prototype.setIcon=function looks like iconUrl is getting the value just fine. I checked mapstraction.drupal.js and marker.setIcon(this.icon); is getting a value as well. If I comment this line out, i get default icons.
#5
Is this really best as an enforced option? When setting up a view at the moment the Icon URL field is a required field. Wouldn't it be better to default to, well, default icon markers, and give users the option to select custom icon fields if they wish to?
#6
I'd also vote for having a default, not all views results will involve images suitable for use as an icon.
#7
As a stop-gap what I've done is:
/sites/all/themes/mytheme/markers/number[counter].pngThis then shows up to 26 numbered icons, which is sufficient for my (current) needs.
#8
thanks for the useful tip.