From b9328a1dc6b029f5c50677363fff159c70dfb836 Mon Sep 17 00:00:00 2001 From: esohns-humana Date: Tue, 2 Apr 2013 18:03:50 +0200 Subject: [PATCH 1/4] repair infoBubble close-button function (OpenLayers) repair missing marker click event delegation (ovi) --- source/mxn.openlayers.core.js | 49 +++++++++++++++++++---------------- source/mxn.ovi.core.js | 2 +- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/source/mxn.openlayers.core.js b/source/mxn.openlayers.core.js index 0d01a08..64056de 100644 --- a/source/mxn.openlayers.core.js +++ b/source/mxn.openlayers.core.js @@ -370,7 +370,7 @@ mxn.register('openlayers', { // handlers : {}, overFeature : function(feature) { var marker = feature.mapstraction_marker; - if (marker.hoverIconUrl) { + if (!!marker.hoverIconUrl) { marker.setUrl(marker.hoverIconUrl); } if (marker.hover && !!marker.popup) { @@ -381,8 +381,8 @@ mxn.register('openlayers', { outFeature : function(feature) { var marker = feature.mapstraction_marker; if (!!marker.hoverIconUrl) { - var icon = marker.iconUrl || 'http://openlayers.org/dev/img/marker-gold.png'; - marker.setUrl(icon); + var iconUrl = marker.iconUrl || 'http://openlayers.org/dev/img/marker-gold.png'; + marker.setUrl(iconUrl); } if (marker.hover && !!marker.popup) { marker.popup.hide(); @@ -406,9 +406,9 @@ mxn.register('openlayers', { // lastPixel : null, autoActivate : true }); - this.controls.drag.handlers.drag.stopDown = false; - this.controls.drag.handlers.drag.stopUp = false; - this.controls.drag.handlers.drag.stopClick = false; + this.controls.drag.handlers.drag.stopDown = false; + this.controls.drag.handlers.drag.stopUp = false; + this.controls.drag.handlers.drag.stopClick = false; this.controls.drag.handlers.feature.stopDown = false; this.controls.drag.handlers.feature.stopUp = false; this.controls.drag.handlers.feature.stopClick = false; @@ -560,12 +560,12 @@ mxn.register('openlayers', { addOverlay: function(url, autoCenterAndZoom) { var map = this.maps[this.api]; var kml = new OpenLayers.Layer.GML("kml", url,{ - 'format': OpenLayers.Format.KML, + 'format' : OpenLayers.Format.KML, 'formatOptions': new OpenLayers.Format.KML({ - 'extractStyles': true, + 'extractStyles' : true, 'extractAttributes': true }), - 'projection': new OpenLayers.Projection('EPSG:4326') + 'projection' : new OpenLayers.Projection('EPSG:4326') }); if (autoCenterAndZoom) { var setExtent = function() { @@ -640,6 +640,7 @@ mxn.register('openlayers', { var lat = (olPoint.lat / 20037508.34) * 180; lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2); this.lon = lon; + this.lng = this.lon; this.lat = lat; } @@ -648,7 +649,7 @@ mxn.register('openlayers', { Marker: { toProprietary: function() { - var size, anchor, style, marker; + var size, anchor, style, marker, position; if (!!this.iconSize) { size = new OpenLayers.Size(this.iconSize[0], this.iconSize[1]); } @@ -683,24 +684,24 @@ mxn.register('openlayers', { // title : this.labelText }; - marker = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point( - this.location.toProprietary('openlayers').lon, - this.location.toProprietary('openlayers').lat), + position = this.location.toProprietary('openlayers'); + marker = new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(position.lon, position.lat), null, style); if (!!this.infoBubble) { this.popup = new OpenLayers.Popup.FramedCloud( null, - this.location.toProprietary('openlayers'), + position, new OpenLayers.Size(100, 100), this.infoBubble, this.icon, - true, - function() {}); + true); this.popup.autoSize = true; this.popup.panMapIfOutOfView = true; this.popup.fixedRelativePosition = false; + this.popup.feature = marker; } else { this.popup = null; @@ -721,8 +722,11 @@ mxn.register('openlayers', { new OpenLayers.Size(100, 100), this.infoBubble, this.icon, - true, - function() {}); + true); + this.popup.autoSize = true; + this.popup.panMapIfOutOfView = true; + this.popup.fixedRelativePosition = false; + this.popup.feature = this.proprietary_marker; } if (!!this.popup) { @@ -734,6 +738,7 @@ mxn.register('openlayers', { if (!!this.popup) { this.popup.hide(); this.map.removePopup(this.popup); + this.popup = null; } }, @@ -756,11 +761,11 @@ mxn.register('openlayers', { var coords = []; var ring; var style = { - strokeColor: this.color, + strokeColor : this.color, strokeOpacity: this.opacity, - strokeWidth: this.width, - fillColor: this.fillColor, - fillOpacity: this.opacity + strokeWidth : this.width, + fillColor : this.fillColor, + fillOpacity : this.opacity }; for (var i = 0, length = this.points.length ; i< length; i++){ diff --git a/source/mxn.ovi.core.js b/source/mxn.ovi.core.js index b21d808..336732e 100644 --- a/source/mxn.ovi.core.js +++ b/source/mxn.ovi.core.js @@ -460,7 +460,7 @@ Marker: { } prop_marker.addListener('click', function (event) { - prop_marker.mapstraction_marker.click.fire(); + prop_marker.mapstraction_marker.click.fire(event); }, false); return prop_marker; From 85b1b522c6b23ce077244a95a4af34552b7d3e99 Mon Sep 17 00:00:00 2001 From: esohns-humana Date: Tue, 9 Apr 2013 13:25:25 +0200 Subject: [PATCH 2/4] repair result parser --- source/mxn.googlev3.geocoder.js | 44 +++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/source/mxn.googlev3.geocoder.js b/source/mxn.googlev3.geocoder.js index d0ee278..79470d3 100644 --- a/source/mxn.googlev3.geocoder.js +++ b/source/mxn.googlev3.geocoder.js @@ -14,14 +14,13 @@ Geocoder: { if (query.hasOwnProperty('lat') && query.hasOwnProperty('lon')) { geocode_request_object.latLng = query.toProprietary(this.api); } - // query is an address object - else{ + else { + // query is an address object geocode_request_object.address = [ query.street, query.locality, query.region, query.country ].join(', '); } } - - // query is an address string else { + // query is an address string geocode_request_object.address = query; } @@ -33,8 +32,7 @@ Geocoder: { geocode_callback: function(results, status){ if (status != google.maps.GeocoderStatus.OK) { this.error_callback(status); - } - + } else { var places = []; @@ -44,45 +42,49 @@ Geocoder: { // lookups; multiple values 'may' be returned but only where there is ambiguity // See https://developers.google.com/maps/documentation/geocoding/#JSON - for (i=0; i 0) { + if ((return_location.street === undefined) && (streetparts.length > 0)) { return_location.street = streetparts.join(' '); } - return_location.point = new mxn.LatLonPoint(place.geometry.location.lat(), place.geometry.location.lng()); places.push(return_location); @@ -101,4 +103,4 @@ Geocoder: { } } -}); \ No newline at end of file +}); From c2c8e7d6bee7e202adcb3168ba9de21d7400e212 Mon Sep 17 00:00:00 2001 From: esohns-humana Date: Wed, 1 May 2013 21:10:38 +0200 Subject: [PATCH 3/4] propagate mouse event to (map) click handler --- source/mxn.googlev3.core.js | 18 +++++++++--------- source/mxn.openlayers.core.js | 11 ++++++----- source/mxn.ovi.core.js | 5 +++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/source/mxn.googlev3.core.js b/source/mxn.googlev3.core.js index b4a3acb..eb7a09a 100644 --- a/source/mxn.googlev3.core.js +++ b/source/mxn.googlev3.core.js @@ -57,11 +57,11 @@ Mapstraction: { myOptions.overviewMapControlOptions = {opened: true}; } } - + var map = new google.maps.Map(element, myOptions); - + var fireOnNextIdle = []; - + google.maps.event.addListener(map, 'idle', function() { var fireListCount = fireOnNextIdle.length; if (fireListCount > 0) { @@ -72,16 +72,16 @@ Mapstraction: { } } }); - + // deal with click - google.maps.event.addListener(map, 'click', function(location){ - me.click.fire({'location': - new mxn.LatLonPoint(location.latLng.lat(),location.latLng.lng()) - }); + google.maps.event.addListener(map, 'click', function(event) { + me.click.fire({'location': new mxn.LatLonPoint(event.latLng.lat(),event.latLng.lng()), + 'event' : event + }); }); // deal with zoom change - google.maps.event.addListener(map, 'zoom_changed', function(){ + google.maps.event.addListener(map, 'zoom_changed', function() { // zoom_changed fires before the zooming has finished so we // wait for the next idle event before firing our changezoom // so that method calls report the correct values diff --git a/source/mxn.openlayers.core.js b/source/mxn.openlayers.core.js index 64056de..e9308c7 100644 --- a/source/mxn.openlayers.core.js +++ b/source/mxn.openlayers.core.js @@ -66,32 +66,33 @@ mxn.register('openlayers', { displayOutsideMaxExtent: true } ); - + // deal with click map.events.register('click', map, function(evt){ var lonlat = map.getLonLatFromViewPortPx(evt.xy); var point = new mxn.LatLonPoint(); point.fromProprietary(api, lonlat); - me.click.fire({'location': point }); + me.click.fire({'location': point, + 'event' : evt}); }); // deal with zoom change map.events.register('zoomend', map, function(evt){ me.changeZoom.fire(); }); - + // deal with map movement map.events.register('moveend', map, function(evt){ me.moveendHandler(me); me.endPan.fire(); }); - + // deal with initial tile loading var loadfire = function(e) { me.load.fire(); this.events.unregister('loadend', this, loadfire); }; - + for (var layerName in this.layers) { if (this.layers.hasOwnProperty(layerName)) { if (this.layers[layerName].visibility === true) { diff --git a/source/mxn.ovi.core.js b/source/mxn.ovi.core.js index 336732e..ef3bb1e 100644 --- a/source/mxn.ovi.core.js +++ b/source/mxn.ovi.core.js @@ -24,7 +24,8 @@ Mapstraction: { // Handle click event ovi_map.addListener('click', function(event){ coords = ovi_map.pixelToGeo(event.targetX, event.targetY); - me.click.fire({'location': new mxn.LatLonPoint(coords.latitude, coords.longitude)}); + me.click.fire({'location': new mxn.LatLonPoint(coords.latitude, coords.longitude), + 'event' : event}); }, false); // Handle endPan (via centre change) and zoom events @@ -402,7 +403,7 @@ Marker: { toProprietary: function() { var properties = {}; var self = this; - + if (this.iconAnchor) { properties.anchor = [this.iconAnchor[0], this.iconAnchor[1]]; } From 40f44fd6b65039acbb3fb3dd2d66857624238c83 Mon Sep 17 00:00:00 2001 From: esohns-humana Date: Tue, 21 May 2013 19:11:44 +0200 Subject: [PATCH 4/4] ovi: support polyline opacity --- source/mxn.ovi.core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/mxn.ovi.core.js b/source/mxn.ovi.core.js index ef3bb1e..01e9a23 100644 --- a/source/mxn.ovi.core.js +++ b/source/mxn.ovi.core.js @@ -538,7 +538,7 @@ Polyline: { else { var polyline_options = { 'visibility' : true, - 'color' : this.color, + 'color' : (this.color + (this.opacity * 255).toString(16)), 'stroke' : 'solid', 'width' : this.width };