From a3c18a0b609bf629e32946ddfb0dd7b74433b56c Mon Sep 17 00:00:00 2001 From: Hugo Wetterberg Date: Thu, 13 Aug 2009 14:16:07 +0200 Subject: [PATCH] Added info windows for items shown in simple geo. Added default styling for the micromap. --- css/simple_geo.css | 12 +++++++++++- js/micromap.js | 23 +++++++++++++++++++++-- simple_geo.module | 2 ++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/css/simple_geo.css b/css/simple_geo.css index c4c935e..887c2f7 100644 --- a/css/simple_geo.css +++ b/css/simple_geo.css @@ -1,5 +1,15 @@ -.address-search { +#micro-map-widget .address-search { background-color: #fff; border: 1px solid #000; padding: 2px; +} + +#micro-map-widget { + height: 200px; +} + +#micro-map-info-window { + background-color: #fff; + border: 1px solid #000; + padding: 5px; } \ No newline at end of file diff --git a/js/micromap.js b/js/micromap.js index 6db51e8..63cb7a7 100644 --- a/js/micromap.js +++ b/js/micromap.js @@ -6,7 +6,7 @@ if (google && google.load) { google.load('maps', '2.x'); jQuery(document).ready(function () { - var positions, map_highlight, placeholder, map, icon, tmp_ids, bounds, pos_len, i, lat, lng, pos, marker, default_zoom, default_center, map_state, placeholder_html, micromap_parent, micromap_add_mode; + var positions, info_window, info_window_content, map_highlight, placeholder, map, icon, tmp_ids, bounds, pos_len, i, lat, lng, pos, marker, default_zoom, default_center, map_state, placeholder_html, micromap_parent, micromap_add_mode; positions = jQuery('.geo'); @@ -80,7 +80,14 @@ if (google && google.load) { }); } else { - map.openInfoWindow(marker.getLatLng(),title.get(0).cloneNode(true)); + var pos = map.fromLatLngToContainerPixel(marker.getLatLng()); + info_window_content.empty().append(title.get(0).cloneNode(true)); + var widget_offset = $(placeholder).offset(); + info_window.css({ + 'position': 'absolute', + 'top': pos.y + widget_offset.top, + 'left': pos.x + widget_offset.left + }).show(); } }; }(positions.get(i), marker)); @@ -120,6 +127,18 @@ if (google && google.load) { } map.checkResize(); map.setCenter(center); + info_window.hide(); + }); + + info_window = $('
').appendTo('body'); + info_window.hide(); + info_window_content = $('#micro-map-info-content'); + $('' + Drupal.t('Close') + '').appendTo(info_window).click(function(){info_window.hide();}); + GEvent.addListener(map, "movestart", function(){ + info_window.hide(); + }); + GEvent.addListener(map, "click", function(){ + info_window.hide(); }); } }); diff --git a/simple_geo.module b/simple_geo.module index 5370fef..928d238 100644 --- a/simple_geo.module +++ b/simple_geo.module @@ -22,6 +22,8 @@ function simple_geo_load() { $settings = array(); if(empty($loaded)) { + drupal_add_css(drupal_get_path('module', 'simple_geo') .'/css/simple_geo.css'); + $def_pos = variable_get('simple_geo_default_position', 0); if ($def_pos) { $settings['simple_geo_default_position'] = $def_pos;