Newer
Older
/*global jQuery, Drupal, GEvent, GInfoWindowTab, GLatLng, GLatLngBounds */
if (obj.vars.behavior.autozoom) {
obj.bounds = new GLatLngBounds();
}
});
obj.bind('addmarker', function (marker) {
var m = Drupal.gmap.factory.marker(new GLatLng(marker.latitude, marker.longitude), marker.opts);
GEvent.addListener(m, 'click', function () {
obj.change('clickmarker', -1, marker);
if (obj.vars.behavior.highlight) {
GEvent.addListener(m, 'mouseover', function () {
var highlightColor = '#' + obj.vars.styles.highlight_color;
highlightMarker(obj.map, marker, 'hoverHighlight', highlightColor);
});
GEvent.addListener(m, 'mouseout', function () {
unHighlightMarker(obj.map, marker, 'hoverHighlight');
});
}
if (obj.vars.behavior.extramarkerevents) {
GEvent.addListener(m, 'mouseover', function () {
obj.change('mouseovermarker', -1, marker);
GEvent.addListener(m, 'mouseout', function () {
obj.change('mouseoutmarker', -1, marker);
GEvent.addListener(m, 'dblclick', function () {
obj.change('dblclickmarker', -1, marker);
});
}
/**
* 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(marker.marker.getPoint());
}
// If the highlight arg option is used in views highlight the marker.
if (marker.opts.highlight == 1) {
highlightMarker(obj.map, marker, 'viewHighlight', marker.opts.highlightcolor);
}
});
// Default marker actions.
// Local/stored content
if (marker.text) {
marker.marker.openInfoWindowHtml(marker.text);
}
Brandon Bergren
committed
// Info Window Query / Info Window Offset
if (marker.iwq || (obj.vars.iwq && typeof marker.iwo != 'undefined')) {
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.marker.openInfoWindow(el);
}
// 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);
//}
marker.marker.openInfoWindowHtml(data);
});
}
// Tabbed content
else if (marker.tabs) {
var infoWinTabs = [];
for (var m in marker.tabs) {
if (marker.tabs.hasOwnProperty(m)) {
infoWinTabs.push(new GInfoWindowTab(m, marker.tabs[m]));
}
}
marker.marker.openInfoWindowTabsHtml(infoWinTabs);
}
// 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.setCenter(obj.bounds.getCenter(), Math.min(obj.map.getBoundsZoomLevel(obj.bounds), obj.vars.maxzoom));
}
}
});
// Reset bounds if autozooming
// @@@ Perhaps we should have a bounds for both markers and shapes?
if (obj.vars.behavior.autozoom) {
obj.bounds = new GLatLngBounds();
}
});
// @@@ TODO: Some sort of bounds handling for deletemarker? We'd have to walk the whole thing to figure out the new bounds...
});