5

I want to add a custom marker to the list of markers on the gmap module I tried the following link which is as described below :http://mydrupaltricks.be/article/drupal-7-custom-gmap-markers but it did not worked

<?php
$markerdir = variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers');
?>

By setting the "gmap_markerfiles" variable, we can change the location of our new markers folder. We have to set this variable only once so we put the code in our "my_module.install" file.

<?php
/**
* Implements hook_install().
*/
function my_module_install() {
  variable_set("gmap_markerfiles", drupal_get_path("module", "my_module_name") . "/markers");
}
?>
Now we can create the new "markers" folder in our new module. Gmap expects a .ini file to describe all your markers. We add the file "markers/my_module.ini".
; Defaults
[defaults]
; Note: An empty shadow property will break IE.
; Leave it commented out if you aren't supplying an image.
; shadow = ""
anchorX = 15
anchorY = 17
infoX = 17
infoY = 6

; Marker sets

[drupal]
name = "drupal"
sequence = "marker-green.png"

[salepoint]
name = "salepoint"
sequence = "marker-green.png"

[headquarter]
name = "headquarter"
sequence = "marker-green.png"

[shop]
name = "shop"
sequence = "marker-yellow.png"

closed as unclear what you're asking by kiamlaluno Nov 18 '16 at 15:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

11

You do not really need to write your own module (unless it does something out of the box) in order to use custom markers.

Here is an guide how you can do that (I assume we use gmap module and views module to display google map.

  1. Upload you custom markers to Drupal website, f.x. to your theme folder (i.e. /sites/all/themes/yourtheme/images/markers or another location that suit you more.
  2. In that folder you need to create an INI file and declare your custom markers (give them name etc). See example with 1 custom marker below. enter image description here
  3. Go to gmap settings /admin/config/services/gmap and specify folder where you saved your marker image and ini file (see image below). enter image description here
  4. Now make sure you saved everything and cleared cache.
  5. Go to your view and in the settings you must get your custom marker available (at the bottom). enter image description here
10

Just thought I'd point out in the this somewhat long-running thread that, due to an update, Dmytro Pastovenskyi's answer is no longer valid in 7.x-2.11. The "Custom markers path" field is still present in the UI form at /admin/config/services/gmap, however any value entered there is effectively ignored. What I did to get it working:

  1. Install the Libraries API module (https://www.drupal.org/project/libraries)
  2. Create a directory in sites/all/libraries called "gmap_markers"
  3. Put your ini file and any related images in this folder
  4. Clear the caches
  • I'll add one additional point to this answer.I'm using Gmap Location. If you go to <yoursite>/admin/config/services/gmap_location you can specify which marker you want to use for each content type that has a location field. After following the steps above, my custom marker appeared in the list of markers - choosing it here made it appear on my map fields. – millionleaves Oct 11 '17 at 4:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.