From 78db7e33869fb5dcfca16c261fde1417c3014965 Mon Sep 17 00:00:00 2001 From: Jean-Benoit Date: Sun, 22 Jun 2014 19:39:35 +0200 Subject: [PATCH] Adding autopop option for infowindow --- locationmap.js | 3 +++ locationmap.module | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/locationmap.js b/locationmap.js index f15a028..325ba2f 100644 --- a/locationmap.js +++ b/locationmap.js @@ -27,6 +27,9 @@ google.maps.event.addListener(marker, 'click', function() { infowindow.open(map, marker); }); + if (Drupal.settings.locationmap.popinfo) { + infowindow.open(map, marker); + } // Allow fine tuning of the marker position in admin mode. if (Drupal.settings.locationmap.admin) { diff --git a/locationmap.module b/locationmap.module index e17453a..7ee67da 100644 --- a/locationmap.module +++ b/locationmap.module @@ -160,6 +160,13 @@ function locationmap_admin_settings($form, &$form_state) { '#format' => $locationmap_info['format'], '#description' => t('The description that will be shown when a user clicks on the marker. If this field is empty, the address will be used.'), ); + + $form['info']['locationmap_popinfo'] = array( + '#type' => 'checkbox', + '#title' => t('Pop Information on load'), + '#description' => t('Do you want the infowindow to pop on page load ?'), + '#default_value' => variable_get('locationmap_popinfo', false), + ); $form['info']['locationmap_body'] = array( '#type' => 'text_format', @@ -261,6 +268,7 @@ function locationmap_page() { $locationmap_settings = array( 'address' => variable_get('locationmap_address', 'Fiordland, New Zealand'), 'info' => $locationmap_info['value'], + 'popinfo' => variable_get('locationmap_popinfo', false), 'lat' => variable_get('locationmap_lat', '-46.0868686'), 'lng' => variable_get('locationmap_lng', '166.6822074'), 'zoom' => variable_get('locationmap_zoom', 10), @@ -342,19 +350,19 @@ function locationmap_in_place_edit_form($form, &$form_state) { '#suffix' => '

', ); $form['locationmap_lat'] = array('#type' => 'textfield', - '#title' => t('Latitude'), + '#title' => t('Latitude'), '#default_value' => variable_get('locationmap_lat', ''), ); $form['locationmap_lng'] = array('#type' => 'textfield', - '#title' => t('Longitude'), + '#title' => t('Longitude'), '#default_value' => variable_get('locationmap_lng', ''), ); $form['locationmap_zoom'] = array('#type' => 'textfield', - '#title' => t('Zoom level'), + '#title' => t('Zoom level'), '#default_value' => variable_get('locationmap_zoom', ''), ); $form['submit'] = array( - '#type' => 'submit', + '#type' => 'submit', '#value' => t('Save new location and zoom level'), ); return($form); @@ -482,12 +490,13 @@ function locationmap_block_image() { 'format' => filter_default_format(), ); $locationmap_info = variable_get('locationmap_info', $locationmap_info_defaults); - + drupal_add_js('//maps.google.com/maps/api/js?v=3&sensor=false', array('type' => 'external', 'weight' => 5)); drupal_add_js($path . '/locationmap.js', array('type' => 'file', 'weight' => 6, 'scope' => 'footer')); $locationmap_settings = array( 'address' => variable_get('locationmap_address', 'Fiordland, New Zealand'), 'info' => $locationmap_info['value'], + 'popinfo' => variable_get('locationmap_popinfo', false), 'lat' => variable_get('locationmap_lat', '-46.0868686'), 'lng' => variable_get('locationmap_lng', '166.6822074'), 'zoom' => variable_get('locationmap_zoom', 10), -- 1.8.3.msysgit.0