Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/mxn.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
};
Expand All @@ -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;
};
Expand Down
14 changes: 13 additions & 1 deletion source/mxn.google.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.lat(), location.lng()) });
}

// If the user puts their own Google markers directly on the map
Expand Down Expand Up @@ -498,6 +498,18 @@ Marker: {

Polyline: {

fromProprietary: function(gpolyline) {
var points = [];

for (var i = 0; i < gpolyline.getVertexCount(); i++) {
point = new mxn.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++){
Expand Down
49 changes: 45 additions & 4 deletions source/mxn.googlev3.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -592,6 +616,22 @@ Marker: {

Polyline: {

fromProprietary: function(gPolyline) {
var points = [];
var path = gPolyline.getPath();

for (var i = 0; i < path.getLength(); i++) {
point = new mxn.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++) {
Expand All @@ -606,8 +646,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);
}
Expand Down