Although i'm loathe to add another "Can i haz the code cuz itz borken!??!" post to drupal.org, i'm afraid i do need to reach out with a pretty general support request. I've just upgraded to 7.x-1.0 from a dev version (sorry, i can't be entirely sure, but i think it was this snapshot) and now my maps—which are all generated by views—are all displaying no results content.

I've checked to ensure the Leaflet library is in place, that i've run all updates, flushed all caches, ran cron, blah blah. However, nothing seems to bring the maps back into display.

If anyone has any nudges in the right direction, i'd be very grateful. I've attached exports of the views, if it's of any value.

Comments

stephen Piscura’s picture

Issue summary: View changes
Sel_Space’s picture

I have the same issue

gmclelland’s picture

I have a similar issue. On one of my views the data strangely appears when you uncheck the "Hide Empty" under the Leaf Map Settings in the view.

Maybe it is somehow related to everyone's problem.

Can someone try that and see if that works for you?

gmclelland’s picture

I think it might be related to this commit http://drupalcode.org/project/leaflet.git/commitdiff/4c30f8d0ea07f89d9d8...

Look at the code at the bottom:

      if (isset($this->options['hide_empty']) && $this->options['hide_empty']) {
        return '';
      }
      else {
        return leaflet_build_map($map, $data, $this->options['height'] . 'px');
      }

I replaced that with the older version:

      if (!empty($data) || (isset($this->options['hide_empty']) && !$this->options['hide_empty'])) {
         return leaflet_build_map($map, $data, $this->options['height'] . 'px');
       }

Then the map seemed to work again. I'll try to create a patch if other people can confirm that the "Hide Empty" checkbox is causing the problem.

I'm rushing through this post so I might not have studied the code very well, but I think the problem might be somewhere close.

hutch’s picture

I would suggest

if (empty($data) && isset($this->options['hide_empty']) && $this->options['hide_empty']) {
  return '';
}
return leaflet_build_map($map, $data, $this->options['height'] . 'px');

If $data is empty and "hide_empty" is TRUE then return nothing, otherwise return the map

gmclelland’s picture

Status: Active » Needs review
StatusFileSize
new845 bytes

Here is a patch based on @hutch's recommendations. Seems to work for me.

stephen Piscura’s picture

Category: Support request » Bug report
Priority: Normal » Major

Forgive me if these tag changes are incorrect, but i think this qualifies as a serious bug. Thanks to those who are offering insights and solutions.

stephen Piscura’s picture

@gmclelland: Thanks for the patch! It brought my maps back.

Now that they're back, however, my marker clusters are no longer displaying. Possibly related to #2144935: Broken with latest Leaflet Dev Version?

stephen Piscura’s picture

StatusFileSize
new143.17 KB

gmclelland and others,

Is anyone experience a huge performance hit when using the patch? I'm getting a whole lot of this:

Screen capture of Views-generated Leaflet map not loading properly

gmclelland’s picture

@stephen Piscura - I could be wrong, but I think your other problems are unrelated to this. With the patch in #6 my views are working correctly.

Some things you might check:
How many markers are you loading? - A bunch of markers can cause a frontend performance problem.
Check the web page's source and make sure your javascript is in the markup.
Try testing by making a simple view that uses a leaflet map. Does it work?

gmclelland’s picture

Just a guess, but when looking at leaflet_markercluster javascript there is a comment that says it is overriding the leaflet js

/*
* We are overriding a large part of the JS defined in leaflet (leaflet.drupal.js).
* Not nice, but we can't do otherwise without refactoring code in Leaflet.
*/

Try disabling that module and see if the leaflet module now works for you.
My guess is that module hasn't been updated yet with all the new changes in the leaflet module.

Hope that helps

stephen Piscura’s picture

gmclelland,

Wow, yeah that did it. The map's performance is fine now. So i think you're right, the marker clusters module is just incompatible with the latest version of Leaflet. Many thanks for digging in to find that...

hutch’s picture

Markercluster (fresh git clone) works fine with Leaflet.js version 0.7
To get the markercluster plugin to work, you need to group your markers and instead of loading them into a layerGroup,
eg line 46 in current dev leaflet.drupal.js

var lGroup = new L.LayerGroup();

Markercluster needs to use something like

var lGroup = L.markerClusterGroup();

Of course steps will have to be taken to ensure that only features that are markers (points) are handled this way.
You should also ensure that leaflet.markercluster.js is loaded before leaflet.drupal.js

mondrake’s picture

Confirm #11, disabling markercluster map shows fine. With markercluster enabled, browser console throws 'Uncaught TypeError: Cannot read property 'bounds' of undefined' on 'Drupal.leaflet.create_point'.

barryvdh’s picture

Also had this problem. I reverted to 7.x-1.0-beta3+44-dev to get the MarkerCluster to work again.

leoklein’s picture

Oy, same nightmare. The older version of Leaflet worked.

Thanks for the tip - #15!

rdeboer’s picture

Assigned: Unassigned » rdeboer
Status: Needs review » Fixed

I have checked in a number of changes to Leaflet MarkerCluster 7.x-1.x to make it compatible again after the changes made to Leaflet, in particular leaflet.drupal.js.
I've done some brief testing and found that the following combination of module versions seems to work when used together (and probably as a subset).
As of today, none of the versions below require patches

Leaflet 7.x-1.x-dev
Leaflet More Maps 7.x-1.7 or 7.x-1x-dev
Leaflet MarkerCluster 7.x-1.x-dev
IP Geolocation Views and Maps 7.x-1.x-dev

gmclelland’s picture

Status: Fixed » Active

Hi Rick, I just tested the latest dev and it still doesn't seem to be fixed. I'm not using the Leaflet Marker Cluster module.

I still have to use the patch in #6 https://drupal.org/comment/8241983#comment-8241983 to get it to work correctly.

Just thought I would let you know

rdeboer’s picture

Status: Active » Fixed

@gmclelland:

Thanks for mentioning. I don't use the Leaflet Views interface myself, I'm using IPGV&M for that (come and join the dark side, Luke!).

But I have just checked in the patch from #6, so for those wishing to use Leaflet Views, you should be fine now.

Thank you hutch and gmclelland.

Rik

pixelsweatshop’s picture

Status: Fixed » Needs work

Sorry, Rik. I hate to revert this issue, but it doesn't seem to be resolved in the latest dev.

rdeboer’s picture

@nicoz
See #17
You need to use very latest 7.x-1.x-dev of ALL those modules if you use them.
If after refreshing caches it still doesn't work please provide reproducible test case.
Rik

pixelsweatshop’s picture

I think that is the issue here, Rik. In this situation I am just running the dev version of the leaflet module and leaflet views. I am not using Leaflet More Maps, Leaflet MarkerCluster, and IP Geolocation Views and Maps. IPGV&M is great on some other stuff we are doing but is not needed in this particular case. This may be why you cannot replicate the issue.

However, now that I have setup a dev box to show you the issue, leaflet views maps are now showing. Not sure why they are missing when working locally and fine when I move it up to a public URL.

Either way, Geocoder is now complaining:

Exception: Google API returned bad status.\nStatus: ZERO_RESULTS in geocoder_google() (/sites/all/modules/geocoder/plugins/geocoder_handler/google.inc).

#1982688: GeoJSON boundaries fail to render with Geofield 2.x

I am going to have to debug this some more to see if I can isolate the issue and report back.

rdeboer’s picture

@nicoz

Well all I can say is that everything works for me. With or without Leaflet MarkerCluster. With or without Leaflet More Maps. And with or without IP Geolocation Views and Maps. Provided you use 7.x-1.x-dev versions of all the module you decide to enable.

The only gotcha I found is that after disabling Leaflet More Maps you need to save the Leaflet View again as it was likely set to a map other than the only one supported by Leaflet when operating by itself. If you don't do that you'll see your markers but on a grey background.

Must add that I don't use Geocoder at the moment.

The Geocoder error is interesting. If that's due to an error orginating in javascript, then the browser is likely to have abandoned any further execution and thus the Leaflet JS doesn't get run....

Check your browser console...

Rik

gcb’s picture

Status: Needs work » Postponed (maintainer needs more info)
pixelsweatshop’s picture

Well all I can say is that everything works for me. With or without Leaflet MarkerCluster. With or without Leaflet More Maps. And with or without IP Geolocation Views and Maps. Provided you use 7.x-1.x-dev versions of all the module you decide to enable.

That's good to know. There must be something in this particular setup that is causing this. I have never had these issues before and I have built a ton of other mapping projects with these modules.

Check your browser console

No errors there, nor in dblog.

I haven't changed a thing since my last post on the 17th and geocoder is no longer complaining about Exception: Google API returned bad status.\nStatus: ZERO_RESULTS in geocoder_google() (/sites/all/modules/geocoder/plugins/geocoder_handler/google.inc).
It must have been a temp API issue on their end. Either way, this part is beyond the scope of this thread.

It also appears that there is a 0.7.2 release of the library on the 17th as well. Not sure if #2152423: Leaflet Library 0.7.1: The version of the Leaflet library could not be detected which fixed support for 0.7.1 is related to this one then.

Too many moving parts on this one for me to properly trace the issue easily. I'll keep poking at it and report back. We can keep this as "Postponed (maintainer needs more info)" until I have something for you or someone else can chime in if they are still experiencing it.

p.s. As always, thanks for your time, Rik. You are a gentleman and a scholar. :)

rdeboer’s picture

@nicoz

Thank you for your kind words.
Look forward to any findings you wish to share with us, Nico!
Rik