Tag Archives: Drupal 6

Using the GMap Module with Drupal’s Private File System

If you use the GMap module with your Drupal installation, something you may not realise initially is that a file is created in your Drupal file system called gmap_markers.js.

By default this file goes in sites/default/files/js/gmap_markers.js and is not the same file as the gmap_marker.js file in the Drupal module directory.

When the Drupal private file system is enabled, you cannot directly access a file in the sites/default/files directory, this means that when the the gmap_markers.js file is looked up, Drupal doesn’t allow access to it. Fortunately, GMaps provides a way around this.

Change the location of gmap_markers.js

The first thing you need to do to resolve this issue is to change where the gmap_markers.js file is located. The next thing you need to do is to tell GMap where to find it.

  1. Pick a location outside of the Drupal file system. For example, files/js/gmap_markers.js instead of sites/default/files/js/gmap_markers.js
  2. In your Drupal administration section, go to your GMaps settings and below the “Google Maps API Key” text box, there will be an option to specify the path to gmap_markers.js from the Drupal root directory.
  3. Enter the path.
  4. Save the changes.
  5. Click the “Regenerate” button in the “Regenerate Marker Cache” section.

Your cache should now be rebuilt in the new location using these settings. This should resolve any private file system issues relating to the GMap module in Drupal 6. Drupal 5 may vary a bit and I have not tested this, but I suspect it should still resolve the problem, for the most part, but you may need to use a different directory than what I suggested.

Good luck, if you have any issues or other tips, such as for Drupal 5, I’d love to hear about them in the comments.