Newer
Older
/*global jQuery, Drupal, GEvent, GInfoWindowTab, GLatLng, GLatLngBounds */
var infowindow = null;
obj.bounds = new google.maps.LatLngBounds();
marker.opts.position = new google.maps.LatLng(marker.latitude, marker.longitude);
marker.opts.map = obj.map;
var m = Drupal.gmap.factory.marker(marker.opts);
google.maps.event.addListener(m, 'click', function () {
if (obj.vars.behavior.highlight) {
google.maps.event.addListener(m, 'mouseover', function () {
var highlightColor = '#' + obj.vars.styles.highlight_color;
haiiro.shimeji
committed
highlightMarker(obj, marker, 'hoverHighlight', highlightColor);
google.maps.event.addListener(m, 'mouseout', function () {
haiiro.shimeji
committed
unHighlightMarker(obj, marker, 'hoverHighlight');
if (obj.vars.behavior.extramarkerevents) {
google.maps.event.addListener(m, 'mouseover', function () {
google.maps.event.addListener(m, 'mouseout', function () {
google.maps.event.addListener(m, 'dblclick', function () {
});
}
/**
* Perform a synthetic marker click on this marker on load.
*/
if (marker.autoclick || (marker.options && marker.options.autoclick)) {
}
if (obj.vars.behavior.autozoom) {
obj.bounds.extend(new google.maps.LatLng(marker.latitude, marker.longitude));
// If the highlight arg option is used in views highlight the marker.
if (marker.opts.highlight == 1) {
haiiro.shimeji
committed
google.maps.event.addListener( obj.mm, 'loaded', function() {
highlightMarker(obj, marker, 'viewHighlight', marker.opts.highlightcolor);
} );
});
// Default marker actions.
// Close infowindow if open to prevent multiple windows
if (infowindow != null){
infowindow.close();
}
infowindow = new google.maps.InfoWindow();
infowindow.open(obj.map, marker.marker);
Brandon Bergren
committed
// Info Window Query / Info Window Offset
else if (marker.iwq || (obj.vars.iwq && typeof marker.iwo != 'undefined')) {
Brandon Bergren
committed
var iwq, iwo;
if (obj.vars.iwq) {
iwq = obj.vars.iwq;
}
if (marker.iwq) {
iwq = marker.iwq;
}
iwo = 0;
if (marker.iwo) {
iwo = marker.iwo;
}
// Create a container to store the cloned DOM elements.
var el = document.createElement('div');
// Clone the matched object, run through the clone, stripping off ids, and move the clone into the container.
jQuery(iwq).eq(iwo).clone(false).find('*').removeAttr('id').appendTo(jQuery(el));
marker.setContent(el);
infowindow.open(obj.map, marker.marker);
Brandon Bergren
committed
}
// AJAX content
var uri = marker.rmt;
// If there was a callback, prefix that.
// (If there wasn't, marker.rmt was the FULL path.)
if (obj.vars.rmtcallback) {
uri = obj.vars.rmtcallback + '/' + marker.rmt;
}
// @Bevan: I think it makes more sense to do it in this order.
// @Bevan: I don't like your choice of variable btw, seems to me like
// @Bevan: it belongs in the map object, or at *least* somewhere in
// @Bevan: the gmap settings proper...
//if (!marker.text && Drupal.settings.loadingImage) {
// marker.marker.openInfoWindowHtml(Drupal.settings.loadingImage);
//}
infowindow.setContent(data);
infowindow.open(obj.map, marker.marker);
// Tabbed content
var data = "";
//tabs in an infowindow is no longer supported in API ver3.
infowindow.setContent(data);
infowindow.open(obj.map, marker.marker);
// No content -- marker is a link
// If we are autozooming, set the map center at this time.
if (obj.vars.behavior.autozoom) {
if (!obj.bounds.isEmpty()) {
obj.map.fitBounds(obj.bounds);
var listener = google.maps.event.addListener(obj.map, "idle", function() {
if (obj.vars.maxzoom) {
var maxzoom = parseInt(obj.vars.maxzoom)
if (obj.map.getZoom() > maxzoom) obj.map.setZoom(maxzoom);
google.maps.event.removeListener(listener);
}
});
// Reset bounds if autozooming
// @@@ Perhaps we should have a bounds for both markers and shapes?
if (obj.vars.behavior.autozoom) {
obj.bounds = new google.maps.LatLngBounds();
}
});
// @@@ TODO: Some sort of bounds handling for deletemarker? We'd have to walk the whole thing to figure out the new bounds...
});