Leaflet includes a nice way to use HTML for markers, which lets you control marker style via CSS. Very useful.

http://leafletjs.com/reference.html#divicon

Users should have the option of using traditional markers or using custom HTML, particularly when using the Views plugin.

Comments

milesw’s picture

Status: Active » Needs review
StatusFileSize
new3.14 KB
new87.9 KB
new40.63 KB

Here's a first shot at the Views support. If this is a desirable feature I'll work on it more.

Views config, under the "Map Icon" fieldset:

Map markers using result counter from Views, with minimal CSS styles:

afeijo’s picture

This is great, I was just looking for a way to change the default blue marker :)
I will test your patch asap, thanks!

t_hall’s picture

Exactly what I'm looking for, really opens up the scenarios the module can be used for.

One issue though, are there any plans to apply the patch to work with leaflet ip_geoloc ?

Thanks for this!

milesw’s picture

@travishall: I'm not familiar with that module. Does it just use the default Leaflet markers?

t_hall’s picture

http://drupal.org/project/ip_geoloc

Yep it uses the leaflet marker by default, you can also select image markers to differentiate by a field in the view, the use of Divicon would really open up the possibilities of the module and expand the current mapping use cases.

My current use case is a Ip_geoloc leaflet map of rental houses centered on the current users location that shows nearby properties and their rental prices on the marker. It would be great to be able to use this patch it with the geolocation functionality of ip_geoloc. Great work!

milesw’s picture

Hmm, looks like that would definitely need to happen in the ip_geoloc module. It includes a Views plugin specifically for Leaflet. You should add a feature request in that module's issue queue.

rdeboer’s picture

What a coincidence!
Only just came across this thread. Looks like we have a case of "great minds think alike"!

Have been having a similar discussion over at http://drupal.org/node/1933600#comment-7155002, which looks very much like @travishall's use-case.

The IP Geoloc Views and Maps feature (available in the dev snapshot) in that issue still uses the image, but adds the Views field as tag.
I can easily extend that functionality to incorporate what is shown above in this thread by suppressing the image (or better: rendering it as a DivIcon as shown here) and just render the content of the Views tag with the CSS class provided.

Rik -- maintainer of IP Geoloc Views and Maps

EDIT: I've done this; so in IP Geoloc V & M you can now have numbered/tagged markers as well as numbers/tags by themselves (without marker icons)

gcb’s picture

Good stuff. Added to the latest Dev with some interface tweaks. Look for a new point release soon.

gcb’s picture

Issue summary: View changes
Status: Needs review » Fixed
yannickoo’s picture

Oh, why did you not camelCase the html_code key?

yannickoo’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ultimike’s picture

Status: Closed (fixed) » Active

Hmm - I don't understand. @gcb indicates in comment 8 that this was committed in November, 2013, but I don't see this functionality in the latest version (released Januray, 2014).

-mike

yannickoo’s picture

Here you can see the commit.

ultimike’s picture

@yannickoo,

Thanks for the quick reply - I agree that it was committed. Looking back through the commit log, it appears that the relevant code was refactored several times, but I think the original intent of this case was lost somewhere along the way.

As far as I can tell, there is no way, when creating a view that uses the Leaflet Map format, to customize the HTML or CSS class of markers, as is outlined in comment 1 above.

-mike

milesw’s picture

Status: Active » Closed (fixed)

I created a new issue with a fix for the views support.

#2327711: Fix views support for DivIcon (HTML) markers

Closing this issue out.