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

I'm adding a gmap from a .tpl, this is my code:

$map = array();
$map['markers'] = $markers;

$element = array(
  '#type' => 'gmap',
  '#gmap_settings' => $map,
);
$output = drupal_render($element);
print_r($output);

The map is loaded succesfully but the JS libraries are being added twice on header. My temporary workaround was to comment line 983 from gmap.module.

// Track the mapids we've used already.
  static $mapids = array();

  //_gmap_doheader(); <-- comment this line

  $mapid = FALSE;
  if (isset($element['#map']) && $element['#map']) {

Comments

johnv’s picture

IMO this is introduced in commit #1061444-64: Javascript is required to view this map.: missing gmap_markers.js.
See also it's initial analysis in #13.

several functions do the same:
- function _gmap_base_js()
- _gmap_doheader()
- gmap_gmap()

podarok’s picture

Version: 7.x-2.3 » 7.x-2.x-dev
Status: Active » Needs work

can anyone provide a working patch for fixing this?

johnv’s picture

@podarok, is the proposed solution the right one?

podarok’s picture

#3 looks like not right
we should check already included js or not and do the right addition

johnv’s picture

Status: Needs work » Active

So, I'll count this as 'no patch'.

johnv’s picture

Issue summary: View changes

Added line commented

johnv’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.