This one is part of META issue #1931138: Fixing all 'single marker' issues

Today I've been trying out marker managers to do some clustering on a map I'm using, and I've run into a problem. I've tried using both Jef Poskanzer's Clusterer and Martin Pearman's ClusterMarker, and when I set the cluster icon to be anything (other than Default for Clusterer), the path to the icon image for cluster markers is wrong.

Looking at the requests in my browser, the problem seems to be that the path being constructed to the cluster icon image is not taking into account the basePath for my Drupal install.

My site's front page:
Path to icon for clusters:

The "subsite/" part isn't making it into the URL for the icon image.

The markers for my non-clustered map items are coming up just fine, which means I'm pretty sure that this is a problem somewhere in the marker manager code. And since it's happening on 2 different marker managers, I figure it must not be specific to which manager I'm using.

I've been looking through the code to try to figure out where the path to these icons gets constructed, but no luck so far. Any pointers or fixes?


#17 gmap_marker_js_fix-1218870.diff476 bytesreeller_sk
PASSED: [[SimpleTest]]: [MySQL] 732 pass(es). View
#7 fix-marker-managers-base-url.patch1.17 KBhadim
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix-marker-managers-base-url.patch. Unable to apply patch. See the log in the details link for more information. View
#1 marker_path-1218870-1.patch388 bytesidflood
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch marker_path-1218870-1.patch. Unable to apply patch. See the log in the details link for more information. View
Members fund testing for the Drupal project. Drupal Association Learn more


idflood’s picture

Version: 6.x-1.1 » 7.x-1.x-dev
388 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch marker_path-1218870-1.patch. Unable to apply patch. See the log in the details link for more information. View

I had the same issue on 7.x-1.x. I've found that the gmap_regenerate_markers function use base_path() but this is not defined yet. The trick is to call drupal_bootrap before using this. On drupal 6 I bet you should have to call conf_init().

Here is a patch for the 7.x-1.x branch.

idflood’s picture

Status: Active » Needs review
smyle’s picture

Priority: Normal » Critical

I have the same issue but the fix is not working for me.

I have tried other things, notably from:
* Change base url in settings.php: $base_url = 'http://mysite/var/www/mysitedirectory/';
--> break the whole site ;
* Hard code the base url in gmap_regenerate_markers:
iconpath in gmap_markers.js is changed to : "http://mysite/var/www/mysitedirectory/sites/all/modules/gmap/markers"
but I still cannot see my markers on the map.

Has someone managed to resolve this issue?
What directory should I see in gmap_markers.js?

Everything else is working correctly on the map, so I suppose accessing the marker image is the issue, but is there a way to check the problem is not somewhere else?

Thanks in advance for your help !

hadim’s picture

Same issue here !

hadim’s picture

I find a way which works for my installation. In gmap.module in function gmap_regenerate_markers():

Add global $base_url; athe beginning of the function.

$contents .= "Drupal.gmap.iconpath = " . drupal_json_encode(base_path() . variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers')) . ";\n";


$contents .= "Drupal.gmap.iconpath = " . str_replace(".", "\/", drupal_json_encode($base_url . "/" . variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers'))) . ";\n";

The thing is, I am using multi site installation so my site subfolder match with my url. After that I just replace "." by "\/".

I don't think this is the cleanest way to resolve this bug but it's actually working :-)

hadim’s picture

I generated a patch according to my last post :

diff -rupN sites/all/modules/gmap/gmap.module sites/all/modules/gmapbk/gmap.module
--- sites/all/modules/gmap/gmap.module	2012-05-09 13:18:05.498794034 +0200
+++ sites/all/modules/gmapbk/gmap.module	2012-05-09 12:01:23.410845758 +0200
@@ -553,11 +553,15 @@ function gmap_menu() {
  * Regenerate the markerdata file.
 function gmap_regenerate_markers() {
+  // this sets the base_path variable
+  global $base_url;
   $contents = '';
   $contents .= "// GMap marker image data.\n";
   $contents .= "Drupal.gmap = Drupal.gmap || {};\n";
-  $contents .= "Drupal.gmap.iconpath = " . drupal_json_encode(base_path() . variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers')) . ";\n";
+//  $contents .= "Drupal.gmap.iconpath = " . drupal_json_encode(base_path() . variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers')) . ";\n";
+  $contents .= "Drupal.gmap.iconpath = " . str_replace(".", "\/", drupal_json_encode($base_url . "/" . variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers'))) . ";\n";
   $contents .= "Drupal.gmap.icondata = " . drupal_json_encode(gmap_get_icondata(TRUE)) . ";\n";
   $dir = "public://js/";
hadim’s picture

1.17 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix-marker-managers-base-url.patch. Unable to apply patch. See the log in the details link for more information. View
haiiro.shimeji’s picture

Sorry, I cannot get the same problem.
Jef Poskanzer's Clusterer works fine with current 7.x-1.x branch, though my drupal is installed in a sub diredtory.

@hadim 's patch seems to assume that base_path() returns the wrong path..
What does base_url() return in your environment?

hbalagtas’s picture

I'm also experiencing the same issue, but only after I transferred the site to the development server from my local environment. @hadim the patch didn't work with my setup.

podarok’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Needs work


git apply --check fix-marker-managers-base-url.patch           
fatal: corrupt patch at line 7

needs reroll against latest head

johnv’s picture

I wonder if this also works if you have multiple subsites, that generate different files, since they are all saved as 'public://js/gmap_markers.js', overwriting eachother.

On a side note: in admin/config/services/gmap, you are instructed to move the file in case the file system is set to 'private'. Does that generate side effects?

podarok’s picture

possibly we should do inline drupal_add_js inclusion for that kind of configurations

podarok’s picture

Status: Needs work » Needs review


Status: Needs review » Needs work

The last submitted patch, fix-marker-managers-base-url.patch, failed testing.

podarok’s picture

this one needs reroll
anyone can help with this issue?
This is the last one critical before 7.x-2.5-beta1 release

johnv’s picture

There are a lot of related issues for this problem.

This issue should resolve both the creation and the inclusion of markers.js.
(a variant of ) Below code snippet must be included in the patch:

--- a/gmap.module
+++ b/gmap.module
@@ -276,7 +276,7 @@ function _gmap_base_js() {
-  $ret['/' . variable_get('file_public_path', conf_path() . '/files') . '/js/gmap_markers.js'] = array(
+  $ret[base_path() . variable_get('file_public_path', conf_path() . '/files') . '/js/gmap_markers.js'] = array(
     'type' => 'external',
     'weight' => 2,
reeller_sk’s picture

476 bytes
PASSED: [[SimpleTest]]: [MySQL] 732 pass(es). View

Here is the patch from #1946494: module calls gmap_marker.js but it doesn't exist duplicated thread .
It contains the snippet on new codebase.

podarok’s picture

Priority: Critical » Major
Status: Needs work » Needs review

lets bump it to bot

johnv’s picture

Status: Needs review » Needs work

#7 and #17 need to be merged.

johnv’s picture

cjamesrun’s picture

#17 worked for 7.x-2.6 installed in the last day or so.

Marker was not showing up. Drupal was installed on a subfolder, and it was looking for it from the root in root/sites/... instead of root/subfolder/sites/....
Thank you

dimitrov.adrian’s picture

#17 Patch is working. +1 for merging.

green_eye55’s picture

Great! #17 worked for me in a subfolder installation.

Thank you! I have spend hours on this issue.

johnv’s picture

Does any one of you (with sites in subfolders) use custom markers. IMO you should need #7, too - not only #17.

dimitrov.adrian’s picture

@johnv actually i am testing my stuffs on d7 installed in subdir and not need from #17, only #7

drtrueblue’s picture

Version: 7.x-2.x-dev » 7.x-2.6

#17 also worked well for 7.x-2.6. Thank you for the support. Perhaps this is easily answered, but will this change eventually get put into place for any future versions or will I have to regularly apply the patch?

fromfriends-de’s picture

After updating to 7.x-2.6 i have lost the markers on different maps. #17 helped to fix this problem. Thanks!

podarok’s picture

Version: 7.x-2.6 » 7.x-2.x-dev
Status: Needs work » Fixed

#17 commited pushed to 7.x-2.x
tagged 7.x-2.7-beta1 release
let`s follow up and see for possible #24 tip in production

If any have bug described and fixed in #7 feel free to reopen and reroll ot against latest dev
Thanks to all!!!

crutch’s picture

#16 fixed for me

Status: Fixed » Closed (fixed)

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

jessicakoh’s picture

I fixed mine by putting "gmap_marker.js" on js folder in gmap module.

jessicakoh’s picture

Issue summary: View changes

Updated issue summary.