Skip to content

Instantly share code, notes, and snippets.

@brunob
Created March 23, 2012 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunob/2168921 to your computer and use it in GitHub Desktop.
Save brunob/2168921 to your computer and use it in GitHub Desktop.
openlayers patch
From 33fa68e80e0fd55241d0d515023a611dd3410129 Mon Sep 17 00:00:00 2001
From: brunob <brunobergot@gmail.com>
Date: Mon, 14 Nov 2011 00:04:44 +0100
Subject: [PATCH 2/3] done : add openBubble and closeBubble to openlayers api
---
source/mxn.openlayers.core.js | 59 ++++++++++++++++++-----------------------
1 files changed, 26 insertions(+), 33 deletions(-)
diff --git a/source/mxn.openlayers.core.js b/source/mxn.openlayers.core.js
index 7ec41a8..334ad28 100644
--- a/source/mxn.openlayers.core.js
+++ b/source/mxn.openlayers.core.js
@@ -475,38 +475,13 @@ mxn.register('openlayers', {
var marker = new OpenLayers.Marker(this.location.toProprietary("openlayers"), icon);
if(this.infoBubble) {
- var popup = new OpenLayers.Popup(null,
- this.location.toProprietary("openlayers"),
- new OpenLayers.Size(100,100),
- this.infoBubble,
- true
- );
- popup.autoSize = true;
- var theMap = this.map;
- if(this.hover) {
- marker.events.register("mouseover", marker, function(event) {
- theMap.addPopup(popup);
- popup.show();
- });
- marker.events.register("mouseout", marker, function(event) {
- popup.hide();
- theMap.removePopup(popup);
- });
- }
- else {
- var shown = false;
- marker.events.register("mousedown", marker, function(event) {
- if (shown) {
- popup.hide();
- theMap.removePopup(popup);
- shown = false;
- } else {
- theMap.addPopup(popup);
- popup.show();
- shown = true;
- }
- });
+ var event_action = "click";
+ if (this.hover) {
+ event_action = "mouseover";
}
+ marker.events.register(event_action, marker, function(event) {
+ marker.mapstraction_marker.openBubble();
+ });
}
if(this.hoverIconUrl) {
@@ -527,9 +502,27 @@ mxn.register('openlayers', {
},
openBubble: function() {
- // TODO: Add provider code
+ var popup = new OpenLayers.Popup(null,
+ this.location.toProprietary(this.api),
+ new OpenLayers.Size(100,100),
+ this.infoBubble,
+ true
+ );
+ popup.autoSize = true;
+ this.openInfoBubble.fire({'marker': this});
+ this.map.addPopup(popup);
+ popup.show();
+ this.proprietary_infowindow = popup; // Save so we can close it later
},
-
+
+ closeBubble: function() {
+ if (this.hasOwnProperty('proprietary_infowindow')) {
+ this.proprietary_infowindow.hide();
+ this.map.removePopup(this.proprietary_infowindow);
+ this.closeInfoBubble.fire({'marker': this});
+ }
+ },
+
hide: function() {
this.proprietary_marker.display( false );
},
--
1.7.5.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment