Alo. Let's see if someone can help to solve this issue 'cos I've been looking for a solution but without any good result. I have updated the leaflet module to its newer version and then the library is missing. I have updated also to newest library (0.7.1) and checked that the path is the correct and even the file leaflet.js is inside ..sites/all/libraries/leaflet... drupal does not recognize it. Anyone knows what it is going wrong. I'm not an expert in code so any suggestion will be really appreciate. Thanks in advanced!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Finabluma’s picture

Issue summary: View changes
balancestuff’s picture

I am seeing this issue as well. Digging around it 'works' if you install an ancient version (0.5) of the leaflet library, but not the newer versions. I'm not sure this is a good ongoing solution, though:

Link to version 0.5:
https://pypi.python.org/pypi/js.leaflet/0.5

Finabluma’s picture

Hi balancestuff, thanks for posting, I have tried your suggestion but did not work for me...I wonder what it could be...

balancestuff’s picture

It seems like it 'works' in that the module sees the library, but not actually making the maps.

I'm currently sitting on the newest library version and wondering if I should revert the module back.

balancestuff’s picture

I reverted to leaflet-7.x-1.0-beta3.tar.gz with no luck, unfortunately. Also tried libs including 0.6.4 and 7.0.

jsibley’s picture

I have the leaflet module 7.x-1.0 and the 7.1 library. I've tried putting leaflet.js in sites/all/libraries/leaflet and in sites/all/libraries/leaflet/dist.

Each time Drupal says that "The version of the Leaflet JavaScript Library library could not be detected."

Not sure what else to try.

jsibley’s picture

I should have written 0.7.1 for the library I have installed.

zilla’s picture

ditto - i have the library in the correct place (dist/leaflet.js), then moved to try at leaflet/leaflet.js and in both cases with most recent update, the file is not found and so updating fails!

zilla’s picture

Category: Support request » Bug report

changing this to a bug report because something in the most recent update seems to have broken whatever worked last time...

hawkbreeze’s picture

Had the same problem, I installed leaflet 0.7.1 and I recieved the same error "The version of the Leaflet JavaScript Library library could not be detected."

After some digging in the code the probelm is in leaflet.module line 34

'pattern' => '/version="(\d+\.\d+)"/',

when trying to get the version number only a 2 digit version number is looked for. 0.7.1 is 3 digits and so it fails when library_detect is run.

For a quick workaround I edited line 34 to search for the 3 digits.

'pattern' => '/version="(\d+\.\d+\.\d+)"/',

This is not a good solution as now a 3 digit search is now hard coded but it works, for now. Maybe some better regex would be better that accomodated both 2 and 3 digit version numbers.

balancestuff’s picture

That seems to have fixed the version issue. I'ms till having some maps not working that I will need to trouble-shoot individually.

nandwabee’s picture

The hack by @cannod from #11 works to make the library recognised. I am however unable to get the map to display on my node.

Finabluma’s picture

Thanks cannod #10 for your answer. It was really helpful. Now the library is detected...

Finabluma’s picture

but as nandwabee says, now the problem is to display the map on the node. What is wrong??

xbrianx’s picture

I am having the exact same issues. I just posted a new thread which can probably be deleted, but I think this thread should read the version not detected instead of not found.

the trick on #11 worked for me, but the maps are definitely not showing up.

jmanny’s picture

Same here "Library not found". I've tried with many different ways but none worked

levelos’s picture

Good catch folks, at the time of writing the Leaflet version was 0.7. I believe the following regex pattern will be more flexible moving forward:
'pattern' => '/version="([\d+\.]*\d+)"/'

I'll commit as soon as I get some confirmation that this will work, or other suggestions.

hitfactory’s picture

Confirming pattern in #17 works for both 0.7 and 0.7.1.

xbrianx’s picture

Any ideas as to why the maps are no longer displaying? - I think that before the maps would show up with only the zipcode present now it needs more than that?

jodym’s picture

Confirm #17 worked for me, then just had to clear the drupal cache to get map to show up.

xbrianx’s picture

Yes, maps are showing now.

Finabluma’s picture

I have some troubles that do not solved the issue yet. The library is detected thanks to pattern #17 but now I'm not able to display the maps even if i clear the cache. I want to display stomer trone map form leaflet more maps module. I dont't know if this module is not compatible anymore with leaflet?? Just wondering ... I really don't know what's going on because before to update everything was working fine... any suggestion??

helonaut’s picture

I have the same problem. Library gets detected after patch #17 (no more error in status report), but map is still not showing. Clearing the cache makes no difference.

mondrake’s picture

Confirm #17 fixes the requirements error (update.php runs fine and status report shows library version correctly).
Here also no maps shown. It seems like an issue on the client side, browser console throws "Uncaught ReferenceError: L is not defined" from line 8 of leaflet.drupal.js. It seems like leaflet.js is not attached to the page.

EDIT:

I am using Leaflet in combination with

  • Leaflet Markercluster 7.x-1.0-beta1
  • IP Geolocation Views & Maps 7.x-1.23

to display maps into IPGV&M views.

I have now maps visible having done the following:

Just temp hacks... hoping modules get aligned. I'll file an issue with IPGV&M

TuWebO’s picture

#17 worked for me too!
I've just tested what issue title says, "library not found". After applying the #17 pattern, it works.

Thanks.

Mohammed J. Razem’s picture

Title: library not found » Leaflet Library 0.7.1: The version of the Leaflet library could not be detected
Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
411 bytes

Pattern in #17 also worked great.

Here's a patch to make things handy for maintainers.

likewhoa’s picture

works for me

RdeBoer’s picture

Assigned: Unassigned » RdeBoer
FileSize
1.14 KB

As this is a major issue, I checked in this patch into the branch. It is basically #17/#26 with an additional minor version update.

Users of IP Geolocation Views & Maps: the latest dev snapshot 7.x-1.x-dev works with this latest Leaflet dev snapshot 7.x-1.x-dev and, if so desired, with the existing official release of Leaflet More Maps 7.x-1.7.

RdeBoer’s picture

By the way, the pattern

/version="([\d+\.]*\d+)"/

is still a little fragile, as it insists on double quotes and does not allow spaces around the equal sign.
That's ok for

o.version="0.7.1"

But I noticed when I switched from the minimized to the full source version (so that I could more easily set breakpoints in the code) that the full source uses this as the version string:

  L.version = '0.7.1';

which is not recognised by the pattern.
Maybe something like

/version[\s]*=[\s]*["']([\d+\.]*\d+)["']/

could reliably work for both cases?

kscheirer’s picture

Priority: Major » Critical

#24 worked for me. I'm not using marker cluster, so it was just the pattern patch here and the libraries_load change in ip_geoloc.

Also, I noticed the README for ip_geoloc says to install Leaflet.js into sites/all/libraries/leaflet/dist/, while the Leaflet module's README says sites/all/libraries/leaflet. Does that need to be updated in ip_geoloc as well?

Marking this critical since it prevents any maps from showing up.

kscheirer’s picture

Not sure what the status should be, since RdeBoer already committed a fix.

RdeBoer’s picture

Status: Needs review » Fixed

Based on experiences of people above, the new version pattern that was checked-in at #28 fixes the issue.

PS: Re #30: You must have an old version of ip_geoloc/README.txt. The new version does not mention that directory.

RdeBoer’s picture

I have also 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 JS v0.7.1)
Leaflet More Maps 7.x-1.x-dev
Leaflet MarkerCluster 7.x-1.x-dev (Leaflet.markercluster JS v0.4)
IP Geolocation Views and Maps 7.x-1.x-dev

pmackay’s picture

I'm finding with the latest dev versions that I see a map region with just a grey background, no map tiles are shown. The regex fix in #29 helped to get the leaflet library loading.

RdeBoer’s picture

Do not patch ANYTHING.
All patches required are already included in the 7.x-1.x-dev versions (which were updated 2 days ago).
Leaflet 7.x-1.x-dev
Leaflet More Maps 7.x-1.x-dev
Leaflet MarkerCluster 7.x-1.x-dev
IP Geolocation Views and Maps 7.x-1.x-dev

Rik

shortspoken’s picture

I can confirm that the versions listed in #33 work like a charme out of the box without any patches.

Cheers!

Status: Fixed » Closed (fixed)

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

jeffschuler’s picture

Priority: Critical » Normal
Status: Closed (fixed) » Needs review
FileSize
428 bytes

Reopening. @RdeBoer: I was just about to create a new issue to make the suggestion you made in #29. I had the same problem when I switched to the non-minimized version of the library for debugging.

BTW, I don't believe the brackets around the \ss are necessary.

'pattern' => '/version\s*=\s*["\']([\d+\.]*\d+)["\']/',
int_ua’s picture

Status: Needs review » Reviewed & tested by the community

#38 worked
Don`t forget to clear the cache.
$ drush cc all

funana’s picture

FileSize
36.35 KB

If you have the problem with the "showing grey backround instead of map in default view", then check the settings in eather your View or your Contenttype's display settings.

All zoom values should be set, especially the "Inital zoom level".

Initial Zoom Level Setting in Contenttype Display Settings

Hope that helps :)

PS: #35 worked perfectly for me. Thanks @RdeBoer!

RdeBoer’s picture

Re #40: Great tip @funana!

Re bottom comment in #40: as time has progressed and official versions have come out that include the required modifications, we can now use the official releases of all modules involved.

funana’s picture

Re #40: Great tip @funana!

Thx. Great module, RdeBoer!

Re bottom comment in #40: as time has progressed and official versions have come out that include the required modifications, we can now use the official releases of all modules involved.

Ah, ok. Good to know! I saw, that the stable versions were also pretty new, but took the DEVs instead.

Keep up the good work!

JustMagicMaria’s picture

Hmm... I just updated to the 7.x-1.1 version and I get this when trying to run update.php. Any ideas?

RdeBoer’s picture

@JustMagicMaria, #43

Double-check the path. Did you follow these instructions from the README:
Download the Leaflet library from http://leafletjs.com. Extract it to your drupal root /sites/all/libraries/leaflet. The file 'leaflet.js' must be found at /sites/all/libraries/leaflet/leaflet.js. All other files and folder(s) that come with the library are also needed there.

JustMagicMaria’s picture

Thanks, RdeBoer. I upgraded to 0.7.2 and it seems to be working now.

pmackay’s picture

I found initially the maps were blank after adding the current latest released modules, when there was no data and I'd configured the view to show when empty. When I added a node that would get displayed, then the map tiles started to render.

omegared’s picture

Also...Don't forget to set the correct permissions on the leaflet folder in the libraries folder! After downloading the leaflet library I kept getting the "version could not be detected" error. A simple change to the permissions to made it readable fixed all. I would like to see a reminder message about permissions in along with the current error message.

boabjohn’s picture

Status: Reviewed & tested by the community » Needs work

Hi guys,
Sorry to ask for some help on this one again...
We've got the latest Libraries (7.x-2.1), Leaflet (7.x-1.1+14-dev) and just installed leaflet.js *7.3* which was released back in May 2014.

  • All directories are set to correct ownership and permissions.
  • Caches have been flushed numerous times.
  • Running Debian 7; php5.4.35

Status reports:

Error Leaflet	not detected
The version of the Leaflet library could not be detected.

Where to go from here?
Thanks very much for any assistance.

balagan’s picture

As I remember at some point the directory structure of the leaflet library changed. Maybe this is the cause for this. Well, thet should be solved already...

boabjohn’s picture

I am still seeing this error (and no maps!).
Leaflet is at: 7.x-1.1+14-dev
JS is version 0.7.3
Library is at: ../sites/all/libraries/leaflet/leaflet.js
All permissions are set properly, caches flushed, db updated.
It really should not be this hard, no?
Any clues very gratefully received.
JB

hutch’s picture

The current regex in dev is too complicated:
'/version="([\d+\.]*\d+)"/'

The regex in patch leaflet-version_regex-2152423-37.patch is even worse:
'/version\s*=\s*["\']([\d+\.]*\d+)["\']/'

This one will work:
'/version="([0-9.]+)"/'

This will work with anything containing numbers and dots

If you want to collect the current version something like this will do:

function leaflet_library_version() {
  $version = '';
  $file = libraries_get_path('leaflet') . '/leaflet.js';
  if (file_exists($file)) {
    $contents = file_get_contents($file);
    $regex = '/version="([0-9.]+)"/';
    if (preg_match($regex, $contents, $m)) {
      $version = $m[1];
    }
  }
  return $version;
}
boabjohn’s picture

Hey there @hutch, thanks for the simplified regex, but I'm not having success here. Same problem. I replaced the version only as the function in my leaflet.module actually has a different name to the one you suggest above (libraries vs library)

So I have this now:

function leaflet_libraries_info() {
  $libraries['leaflet'] = array(
    // Only used in administrative UI of Libraries API.
    'name' => 'Leaflet JavaScript Library',
    'vendor url' => 'http://leafletjs.com/',
    'download url' => 'http://leaflet-cdn.s3.amazonaws.com/build/leaflet-0.7.1.zip',
    // .7: version="0.7"
    'version arguments' => array(
      'file' => 'leaflet.js',
      'pattern' => '/version="([0-9.]+)"/'
    ),

And no joy.

Am I missing something still?

(edit) One more note for clarity: I am using the latest Leaflet.js release which is 0.7.3, not 0.7.1 as seems to be advised in the 'download url' ... but I would not have thought that was the issue. The leaflet.js is still ready to be found in the same path under /libraries/.

Funny how it's not reporting "js can't be found"...it's saying "version can't be determined"... I wonder if that is in fact an issue between 0.7.1 and 0.7.3?

(edit edit) In case there's any doubt, I'm not code competent. Looking back over the two functions (one suggested by @hutch and the other from leaflet.module) they are clearly different.
I'm confused enough now...if any kind soul can simplify my siutaion with this module it would be immensely appreciated!

hutch’s picture

If I can find the time I will dig into this, I want to know more about hook_libraries_info() and I don't know if the issue is with leaflet_libraries_info() or not. It provides 'version arguments' but not a 'version callback', looking at the code in libraries.module circa line 577 I get the impression you need both.

hutch’s picture

What I did was copied and renamed the whole of leaflet_libraries_info() to a bespoke module 'myhelper' and messed around in there.
At this point the leaflet module was not installed but the library was installed in /sites/all/libraries/leaflet.

test code:

$name = 'leaflet';

$lib = libraries_get_path($name);
$output .= '<pre>' . print_r($lib, true) . '</pre>';

$lib = libraries_detect($name);
$output .= '<pre>' . print_r($lib, true) . '</pre>';

$lib = &libraries_info($name);
$output .= '<pre>' . print_r($lib, true) . '</pre>';
return $output;

The library was found and its version number returned correctly

I then disabled the hook_libraries_info() in "myhelper" module and flushed cache, installed leaflet module and flushed cache again,
the library was found and its version number returned correctly.
I also tested it on a multisite configuration, that worked too.

So there is nothing wrong with the regex pattern and leaflet_libraries_info() works as it should.

boabjohn’s picture

Hey there @hutch,

Looks like a thorough investigation...I trust your learning goals around hook_libraries_info() are being advanced.
Apologies again, but I'm not quite sure what my next steps would be (as a simple site builder).

I thought about hacking the leaflet.module, trying to piece togehter the changes you've suggested above, but it's really past me.

I'm not sure if I need to start over with a clean install of the latest dev, then add your $name $lib $lib declarations above and replace the library function with your libraries function...or if this is just going to be a mess.

No need for a rolled patch, I'm happy to copy/paste in fragments as needed...I'm just missing the slightly bigger picture of what needs to be changed in the leaflet.module code.

Thanks for your help and generosity with your time.

hutch’s picture

The leaflet module's code does not need to be modded, your problem is with the install of the Leaflet library, that is what you need to sort out.
To test if the library can be found just enable PHP filter and create a page with:

$name = 'leaflet';
$lib = libraries_get_path($name);
$output = '<pre>' . print_r($lib, true) . '</pre>';
print $output;

If nothing appears when you view the page then the path is wrong or read permissions are wrong.

boabjohn’s picture

Well, thanks for the additional assistance: it seems the mystery just deepens.
I used ../devel/php to run the snippet you kindly provided and got this response:

<pre>sites/all/libraries/leaflet</pre>

Now..that's the right path. And sitting in that directory is a leaflet.js file, permissions 0664

And the first few lines of that .js are:

/*
 Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com
 (c) 2010-2013, Vladimir Agafonkin
 (c) 2010-2011, CloudMade
*/
!function(t,e,i){var n=t.L,o={};o.version="0.7.3","object"==typeof module&&
hutch’s picture

That is right path and right file, the mystery does indeed deepen...

Try this snippet, it should return version:

  $version = '';
  $file = libraries_get_path('leaflet') . '/leaflet.js';
  if (file_exists($file)) {
    $contents = file_get_contents($file);
    $regex = '/version="([0-9.]+)"/';
    if (preg_match($regex, $contents, $m)) {
      $version = $m[1];
    }
  }
  print $version;
boabjohn’s picture

FileSize
10.78 KB

@hutch you're a very patient person...and how's this for a further marker into the mystery: your checking snippet correctly returns 0.7.3!

correct

hutch’s picture

OK, so the problem probably lies with the Libraries module, so test that with

$lib = libraries_detect('leaflet');
print print_r($lib, true);

and

$lib = libraries_info('leaflet');
print print_r($lib, true);
boabjohn’s picture

FileSize
1.92 KB
1.98 KB

Ok, both snippets return some response...php01 and php02 attached.

hutch’s picture

You have a module called "recline" with a machine name of "leaflet" which is providing obsolete information, you need to get rid of it and install current Leaflet module, either stable or dev.

    [name] => Leaflet
    [vendor url] => http://leaflet.cloudmade.com
    [download url] => http://leaflet.cloudmade.com/download.html
    [path] => Leaflet/dist/leaflet.js
    [version arguments] => Array
        (
            [file] => Leaflet/dist/leaflet.js
            [pattern] => @majorVersion[=:]["'](\d).+?minorVersion[=:]["']([\d\.]+)@
            [lines] => 6
            [cols] => 100
        )

    [files] => Array
        (
            [js] => Array
                (
                    [leaflet/spec/after.js] => Array
                        (
                        )

                )

            [css] => Array
                (
                    [leaflet/dist/leaflet.css] => Array
                        (
                        )

                )

        )
    [info type] => module
    [module] => recline
    [machine name] => leaflet
    [library path] => sites/all/libraries/leaflet

This should be something like

[name] => Leaflet JavaScript Library
    [vendor url] => http://leafletjs.com/
    [download url] => http://leaflet-cdn.s3.amazonaws.com/build/leaflet-0.7.1.zip
    [version arguments] => Array
        (
            [file] => leaflet.js
            [pattern] => /version="([\d+\.]*\d+)"/
        )

    [files] => Array
        (
            [js] => Array
                (
                    [leaflet_root_url] => Array
                        (
                            [type] => inline
                            [data] => L_ROOT_URL = "/sites/test7c/libraries/leaflet/";
                            [group] => -100
                            [preprocess] => 
                        )

                    [leaflet.js] => Array
                        (
                            [type] => file
                            [group] => -100
                            [preprocess] => 
                        )

                )

            [css] => Array
                (
                    [leaflet.css] => Array
                        (
                            [type] => file
                            [media] => all
                        )

                    [leaflet.ie.css] => Array
                        (
                            [browsers] => Array
                                (
                                    [IE] => lte IE 8
                                    [!IE] => 
                                )

                        )

                )

        )

    [integration files] => Array
        (
            [leaflet] => Array
                (
                    [js] => Array
                        (
                            [leaflet.drupal.js] => Array
                                (
                                )

                        )

                )

        )

    [info type] => module
    [module] => leaflet
    [machine name] => leaflet
    [path] => 
    [library path] => sites/test7c/libraries/leaflet
boabjohn’s picture

Hey there @hutch...thanks heaps for tracking this down.
Recline comes from the DKAN profile (DKAN Datastore module). I will pass this report on to the devs over there for further action.
Kind regards,
JB

SocialNicheGuru’s picture

RdeBoer’s picture

Status: Needs work » Closed (fixed)

The latest pattern checked in can handle version strings like:

version: '0.7.5'
and
version:"1.0.0-beta.2"

andyrandom’s picture

I don't know if there is a newer version of this thread out there, but Leaflet 1.2.0 broke my module. It seems to be because the version number is specified way down in the JS file. I had to add a line to leaflet.module to make it search down that far - by default the Libraries module only checks the first 20 lines of a JS file for a version number. So I added this:

'lines' => 1200,

after the pattern definition on line 58.

Now Libraries finds the version number and everything is OK.

HansKuiters’s picture

@andyrandom: thanks!

stpaultim’s picture

GuillaumeDuveau’s picture

When you download Leaftlet, leaflet.js is the minified version so it's harder to find the version number.
Instead of patching you can just rename leaflet.js to leaflet.min.js (or delete it) and rename leaflet-src.js to leaflet.js.

dmegatool’s picture

I had to do 2 things to make it work.

I added 'lines' => 1200 on line 58 in leaflet.module. Like so :

      'pattern' => '/version[=: ]*[\'"]([\d+\.]+[\-a-z\.\d]*)[\'"]/',
      'lines' => 1200

And added the version (from the src version) in the minified version of the library js. Leaflet.js is like so :

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.L={})}(this,function(t){"use strict";var version = "1.3.1+HEAD.ba6f97f";function  .... 

That's 2 solution I've seen talked around but I needed both. If I do only one of them, I still get the "version not detected" on the report page.

kscheirer’s picture

This issue was closed 2 years ago, please file a new issue if there is a problem. Lots of people will not see any updates on a closed issue.

Joel MMCC’s picture

Please see my #2895968-15: Leaflet v1.3.1 and newer 1.x version not recognized. I'm a n00b at Drupal development, but I think we may be going about this whole version-detection thing the wrong way.

jansohan’s picture

The best solution for this issue is need to install this module the Libraries API.
Then check Libraries status in /admin/reports/libraries. Then download the particular Leaflet Library from the list and upload to /sites/all/libraries.
Then check the status report.

Joel MMCC’s picture

@jansohan #73, How does that handle the version detection issue?

If you read the Related Issue thread #2895968-15: Leaflet v1.3.1 and newer 1.x version not recognized you’ll see more what the underlying issue is. Right now they’re trying to determine the version number by parsing the source code with a RegEx. The Leaflet people apparently don’t like that, and have made the version number more complex including adding letters and symbols (“+HEAD”) and moving it to practically the very end of the single-line minimized version (thus defeating the attempt to speed up the detection by only looking at the first couple dozen or so characters of the first couple dozen or so lines) apparently to break such attempts to parse out the version number from the code.

What they want us to do is use the function they provided: L.version . It’s that simple. Yes, it means actually invoking Leaflet instead of just reading the first part of the source code, but you’d only have to do that at install time, upgrade time, when generating Status Report, and maybe when actually loading it which you’d have to load it for anyway, so it’s not like it’d waste a lot of resources in a loop or some such.

But yes, we should also be using the Libraries module and API for this.

Mohammed J. Razem’s picture

CProfessionals’s picture

The above did not resolve the situation for me. The following did...
https://www.drupal.org/project/leaflet/issues/2895968#comment-12982620 #40