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:

  1. Add a CCK text field to a node type that appears in your map.
  2. Enter a URL to your custom icon in this node field.
  3. Map the field with the "Icon URL" field in the Mapstraction view style options.
  4. 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...

AttachmentSize
icons.patch1.67 KB

#1

dixon_ - May 6, 2009 - 14:39

Rerolled this patch after committing #437644: Set initial point dynamically. Still needs to fix element descriptions.

AttachmentSize
icons-2.patch 1.75 KB

#2

dixon_ - May 6, 2009 - 15:16
Status:needs review» needs work

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

febbraro - June 26, 2009 - 13:39

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

jmullins - August 20, 2009 - 03:48

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

omjn - August 22, 2009 - 11:45

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

DamienMcKenna - September 4, 2009 - 16:10

I'd also vote for having a default, not all views results will involve images suitable for use as an icon.

#7

DamienMcKenna - September 4, 2009 - 16:27

As a stop-gap what I've done is:

  • Copied the markers from the gmap.module :-) to my theme directory
  • Added the "Global: View result counter" field to the view
  • Added a "Global: Custom text" field to the view that is hidden by default
  • Set the field's text to: /sites/all/themes/mytheme/markers/number[counter].png
  • Set Mapstraction to use this new field for the icon.

This then shows up to 26 numbered icons, which is sufficient for my (current) needs.

#8

omjn - September 5, 2009 - 10:35

thanks for the useful tip.

 
 

Drupal is a registered trademark of Dries Buytaert.