From 815e6e4f4e33264d210ca00893c5a1a4b491bd54 Mon Sep 17 00:00:00 2001 From: thegecko Date: Fri, 3 Jan 2014 20:01:06 +0000 Subject: [PATCH 1/7] Fixed Radius quality calculation, closed property and color check --- source/mxn.core.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/mxn.core.js b/source/mxn.core.js index 2660819..ed36023 100644 --- a/source/mxn.core.js +++ b/source/mxn.core.js @@ -1842,7 +1842,7 @@ var Radius = mxn.Radius = function(center, quality) { var rad = Math.PI / 180; this.calcs = []; - for(var i = 0; i < 360; i += quality){ + for(var i = 0; i < 360; i += 360/quality){ this.calcs.push([Math.cos(i * rad) / latConv, Math.sin(i * rad) / lonConv]); } }; @@ -1868,7 +1868,8 @@ Radius.prototype.getPolyline = function(radius, color) { points.push(points[0]); var line = new Polyline(points); - line.setColor(color); + line.setClosed(true); + if (color) line.setColor(color); return line; }; From 05462322e6089fd33d370203a3e693192c0037b9 Mon Sep 17 00:00:00 2001 From: thegecko Date: Fri, 3 Jan 2014 20:05:11 +0000 Subject: [PATCH 2/7] Fixed location retrieval bug for google click event --- source/mxn.google.core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/mxn.google.core.js b/source/mxn.google.core.js index 598b70c..78126fa 100644 --- a/source/mxn.google.core.js +++ b/source/mxn.google.core.js @@ -14,7 +14,7 @@ Mapstraction: { marker.mapstraction_marker.click.fire(); } else if ( location ) { - me.click.fire({'location': new mxn.LatLonPoint(location.y, location.x)}); + me.click.fire({'location': new mxn.LatLonPoint(location.nb, location.ob)}); } // If the user puts their own Google markers directly on the map From b7f5284d21a17bbcc400e78304ff1299d26637e6 Mon Sep 17 00:00:00 2001 From: thegecko Date: Fri, 3 Jan 2014 20:08:29 +0000 Subject: [PATCH 3/7] Added Polyline.fromProprietary() implementation for google and googlev3 --- source/mxn.google.core.js | 12 ++++++++++++ source/mxn.googlev3.core.js | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/source/mxn.google.core.js b/source/mxn.google.core.js index 78126fa..83d6f15 100644 --- a/source/mxn.google.core.js +++ b/source/mxn.google.core.js @@ -498,6 +498,18 @@ Marker: { Polyline: { + fromProprietary: function(gpolyline) { + var points = []; + + for (var i = 0; i < gpolyline.getVertexCount(); i++) { + point = new LatLonPoint(); + point.fromProprietary('google', gpolyline.getVertex(i)); + points.push(point); + } + + this.points = points; + }, + toProprietary: function() { var gpoints = []; for (var i = 0, length = this.points.length ; i< length; i++){ diff --git a/source/mxn.googlev3.core.js b/source/mxn.googlev3.core.js index 44ea72c..553f240 100644 --- a/source/mxn.googlev3.core.js +++ b/source/mxn.googlev3.core.js @@ -592,6 +592,22 @@ Marker: { Polyline: { + fromProprietary: function(gPolyline) { + var points = []; + var path = gPolyline.getPath(); + + for (var i = 0; i < path.getLength(); i++) { + point = new LatLonPoint(); + point.fromProprietary('googlev3', path.getAt(i)); + points.push(point); + } + + this.points = points; + this.color = gPolyline.strokeColor; + this.opacity = gPolyline.strokeOpacity; + this.width = gPolyline.strokeWeight; + }, + toProprietary: function() { var points = []; for (var i = 0, length = this.points.length; i < length; i++) { From 91b5db699121ca63e32b6f8140e34ae20d672525 Mon Sep 17 00:00:00 2001 From: thegecko Date: Fri, 3 Jan 2014 20:11:51 +0000 Subject: [PATCH 4/7] Fixed closed Polyline(Polygon) options in googlev3 to match google --- source/mxn.googlev3.core.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/mxn.googlev3.core.js b/source/mxn.googlev3.core.js index 553f240..4c4455a 100644 --- a/source/mxn.googlev3.core.js +++ b/source/mxn.googlev3.core.js @@ -622,8 +622,9 @@ Polyline: { }; if (this.closed) { - polyOptions.fillColor = this.fillColor || '#000000'; - polyOptions.fillOpacity = polyOptions.strokeOpacity; + polyOptions.fillColor = this.fillColor || "#5462E3"; + polyOptions.fillOpacity = this.opacity || "0.3"; + polyOptions.strokeWeight = this.width || 0; return new google.maps.Polygon(polyOptions); } From cef2b4d2e9e04c63a83e3a232df1f6e8badfff2a Mon Sep 17 00:00:00 2001 From: thegecko Date: Sat, 4 Jan 2014 10:47:39 +0000 Subject: [PATCH 5/7] Fixed location retrieval bug for google click event (again!) --- source/mxn.google.core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/mxn.google.core.js b/source/mxn.google.core.js index 83d6f15..8dddd66 100644 --- a/source/mxn.google.core.js +++ b/source/mxn.google.core.js @@ -14,7 +14,7 @@ Mapstraction: { marker.mapstraction_marker.click.fire(); } else if ( location ) { - me.click.fire({'location': new mxn.LatLonPoint(location.nb, location.ob)}); + me.click.fire({ 'location': new mxn.LatLonPoint(location.lat(), location.lng()) }); } // If the user puts their own Google markers directly on the map From 47c41c3bd5a2de2ebbb0540c446149b1ea4c5cb4 Mon Sep 17 00:00:00 2001 From: thegecko Date: Sat, 4 Jan 2014 11:03:29 +0000 Subject: [PATCH 6/7] Fixed Polyline.fromProprietary() implementation for google and googlev3 --- source/mxn.google.core.js | 2 +- source/mxn.googlev3.core.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/mxn.google.core.js b/source/mxn.google.core.js index 8dddd66..528ee85 100644 --- a/source/mxn.google.core.js +++ b/source/mxn.google.core.js @@ -502,7 +502,7 @@ Polyline: { var points = []; for (var i = 0; i < gpolyline.getVertexCount(); i++) { - point = new LatLonPoint(); + point = new mxn.LatLonPoint(); point.fromProprietary('google', gpolyline.getVertex(i)); points.push(point); } diff --git a/source/mxn.googlev3.core.js b/source/mxn.googlev3.core.js index 4c4455a..9bd60d1 100644 --- a/source/mxn.googlev3.core.js +++ b/source/mxn.googlev3.core.js @@ -597,7 +597,7 @@ Polyline: { var path = gPolyline.getPath(); for (var i = 0; i < path.getLength(); i++) { - point = new LatLonPoint(); + point = new mxn.LatLonPoint(); point.fromProprietary('googlev3', path.getAt(i)); points.push(point); } From a6bd4d18a847b44e04bdc339fd74814df4f52e18 Mon Sep 17 00:00:00 2001 From: thegecko Date: Wed, 8 Jan 2014 22:26:05 +0000 Subject: [PATCH 7/7] Added missing getPixelRatio function to googlev3 --- source/mxn.googlev3.core.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/source/mxn.googlev3.core.js b/source/mxn.googlev3.core.js index 9bd60d1..001326c 100644 --- a/source/mxn.googlev3.core.js +++ b/source/mxn.googlev3.core.js @@ -413,9 +413,33 @@ Mapstraction: { }, getPixelRatio: function() { - var map = this.maps[this.api]; - // TODO: Add provider code + function distanceBetween(point1, point2) { + var R = 6371; // km (change this constant to get miles) + //var R = 6378100; // meters + var lat1 = point1.lat(); + var lon1 = point1.lng(); + var lat2 = point2.lat(); + var lon2 = point2.lng(); + var dLat = (lat2-lat1) * Math.PI / 180; + var dLon = (lon2-lon1) * Math.PI / 180; + var a = Math.sin(dLat/2) * Math.sin(dLat/2) + + Math.cos(lat1 * Math.PI / 180 ) * Math.cos(lat2 * Math.PI / 180 ) * + Math.sin(dLon/2) * Math.sin(dLon/2); + var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); + var d = R * c; + return d; + } + + var map = this.maps[this.api]; + var projection = map.getProjection(); + var centerPoint = map.getCenter(); + var zoom = map.getZoom(); + var centerPixel = projection.fromLatLngToPoint(centerPoint); + // distance is the distance in metres for 5 pixels (3-4-5 triangle) + var distancePoint = projection.fromPointToLatLng(new google.maps.Point(centerPixel.x + 3, centerPixel.y + 4)); + //*1000(km to m), /5 (pythag), *2 (radius to diameter) + return 10000/distanceBetween(centerPoint, distancePoint); }, mousePosition: function(element) {