At some point the module was refactored to consolidate field formatters. This broke the views support for HTML markers.

The following error is a symptom of this:

Notice: Undefined index: entity in function leaflet_apply_map_settings() (line 394 in...
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

milesw’s picture

Here is a small patch to fix Views support.

milesw’s picture

Status: Active » Needs review
Alex Bukach’s picture

milesw, it seems the path is not against the latest dev version. Here's correct one.

Alex Bukach’s picture

Status: Needs review » Active
Alex Bukach’s picture

Status: Active » Needs review
kufeiko’s picture

Works fine for me, against current 7.x-1.x-dev.

milesw’s picture

Not sure what happened with the original patch. Here's a new one.

Tried #3 but it looks like it was created from Drupal root and won't apply for me.

milesw’s picture

FileSize
3.99 KB

Looks like my last two patches were bad because I had ignored whitespace changes.

This patch should apply without issues.

Alex Bukach’s picture

Thanks for fixing patch path in #8, milesw. Works fine as well.

Alex Bukach’s picture

It appears the we should set iconSize for views as well, otherwise leaflet sets default icon size.

das-peter’s picture

I've still trouble with the patches posted here.
Here's a manual re-roll - no clue if the functionality is as intended.
However I start to test the functionality now.

das-peter’s picture

Just stumbled over notices triggered by the current patch.
The icon size handling should work for html and marker - but currently it deals with a variable that's just available if a marker is configured.
Added condition.

texas-bronius’s picture

das-peter's patch applied OK and provides html output as a leaflet point marker for me. Click event still works to boot :)
I read above about "latest dev" of d.o leaflet module, but that one threw an error for me here:
http://cgit.drupalcode.org/leaflet/commit/?id=d3843bd
Instead, I reverted just the line at the bottom:

-      // Use a Zoomswitch Layer extension to enable zoom-switch option.
-      var map_layer = new L.TileLayerZoomSwitch(layer.urlTemplate);
+      var map_layer = new L.TileLayer(layer.urlTemplate);

and that allowed the plugin as well as the html point style to work.

robertwb’s picture

Folks - I would love to review this and add my support to a RTBC status, but I lack the knowledge of how to use the *@%$#!! DivIcon functionaltiy! If someone on this thread could be so kind as to show some views field config that makes this work, it would not only help me heaps (cause I need this), but as mentioned I will add my $0.02 to the review.

Thanks!

milesw’s picture

@robertwb The option for Views can be found in the Leaflet Map style settings.

1. Make sure "Leaflet Map" is chosen in the Format section of the Views UI.
2. Open the Settings link from the Format section.
3. Open the fieldset named "Point Icon".
4. For "Icon Source" choose "Field (html DivIcon)"
5. For "Marker field" choose the Views field you want to output as your markers.

robertwb’s picture

@milesw - I should have been more clear. I get all of that, it's the actual field HTML that I don't get -- my CSS sucks if that helps you see where I'm coming

milesw’s picture

@robertwb If you're not writing the CSS, you probably don't need this feature. It's meant to give you control over the markup and therefore the style. The field HTML is whatever gets rendered for the Views field you select. You can customize that to be anything you want with Views field rewriting.

robertwb’s picture

@milesw - of course I need this feature, that's why I'm here... but my inexperience with CSS is causing me to fail to check this out. I also understand the field HTML gets rendered, but to construct field HTML that creates a usable custom icon escapes me.

robertwb’s picture

I was able to get going on this -- thanks to those who offered guidance. This patch works as advertised. I also added a related issue, which I created to provide documentation on some use cases for this feature at https://www.drupal.org/node/2390627

bisonbleu’s picture

In reference to @milesw step-by-step in #15.

5. For "Marker field" choose the Views field you want to output as your markers.

If you are wondering what to use for a basic Marker field, do the following.

In Fields, add a Global: custom text field and set its Text to  . You can leave the other settings to default in the Format | Settings UI. When you're done, Leaflet's default blue marker icons will be replaced by small white squares.

You can see this and more sophisticated options by visiting the page created by @robertwb here.

tisteegz’s picture

Patch in #12 worked for me.

FMB’s picture

Working for me too.

apetro’s picture

Patch #12 works in my Drupal setup, too. When in Leaflet module?

robertwb’s picture

Status: Needs review » Reviewed & tested by the community

Marking this RTBC - patch applies against the most recent dev version (albeit with an offset).

  • RdeBoer committed 1c319b9 on 7.x-1.x authored by das-peter
    Issue #2327711 by milesw, das-peter, Alex Bukach: Fix views support for...
RdeBoer’s picture

Patch applied (manually as I've applied so many patches in the last couple of days, the code has changed -- please test 7.x-1.x-dev before we make it an official release!).
Rik

robertwb’s picture

I will begin testing tomorrow - thanks @RdeBoer!

robertwb’s picture

The latest dev version provides this functionality cleanly. Verified over the course of several days now and just moved into production systems. I move to mark this closed.

RdeBoer’s picture

Great!
Thanks for confirming Robert.
Looks like we're almost read to make the current 7.x-1.x-dev the next official release.
I'll give it a little longer because so many patches have been applied recently.
Rik

robertwb’s picture

Sounds good @RdeBoer - I guess it's pretty hard to develop automated testing for mapping/visualization stuff? Talk about an industry need...

robertwb’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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