Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Commit

Permalink
Added info windows for items shown in simple geo. Added default styli…
Browse files Browse the repository at this point in the history
…ng for the micromap.
  • Loading branch information
hugowetterberg committed Aug 13, 2009
1 parent 2a2dbd2 commit a3c18a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
12 changes: 11 additions & 1 deletion 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;
}
23 changes: 21 additions & 2 deletions js/micromap.js
Expand Up @@ -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');

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -120,6 +127,18 @@ if (google && google.load) {
}
map.checkResize();
map.setCenter(center);
info_window.hide();
});

info_window = $('<div id="micro-map-info-window"><div id="micro-map-info-content"></div></div>').appendTo('body');
info_window.hide();
info_window_content = $('#micro-map-info-content');
$('<a class="close_link">' + Drupal.t('Close') + '</a>').appendTo(info_window).click(function(){info_window.hide();});
GEvent.addListener(map, "movestart", function(){
info_window.hide();
});
GEvent.addListener(map, "click", function(){
info_window.hide();
});
}
});
Expand Down
2 changes: 2 additions & 0 deletions simple_geo.module
Expand Up @@ -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;
Expand Down

0 comments on commit a3c18a0

Please sign in to comment.