Skip to content

Commit

Permalink
Update version (0.4.17)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpneo committed Feb 14, 2015
1 parent 57500c8 commit ad937e4
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 45 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ grunt
Changelog
---------

0.4.17
-----------------------
* Remove the http so the library (Google Maps call) will also work under SSL without warnings
* Update route drawing methods to allow 'icons' option for drawPolyline
* Remove dependency on 'grunt-cli' having to be installed globally

0.4.16
-----------------------
* Fix removeMarkers
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gmaps",
"version": "0.4.16",
"version": "0.4.17",
"main": "gmaps.js"
}
87 changes: 60 additions & 27 deletions gmaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
}(this, function() {

/*!
* GMaps.js v0.4.16
* GMaps.js v0.4.17
* http://hpneo.github.com/gmaps/
*
* Copyright 2014, Gustavo Leon
* Copyright 2015, Gustavo Leon
* Released under the MIT License.
*/

Expand Down Expand Up @@ -105,7 +105,7 @@ var arrayToLatLng = function(coords, useGeoJSON) {

for (i = 0; i < coords.length; i++) {
if (!(coords[i] instanceof google.maps.LatLng)) {
if (coords[i].length > 0 && typeof(coords[i][0]) == "object") {
if (coords[i].length > 0 && typeof(coords[i][0]) === "object") {
coords[i] = arrayToLatLng(coords[i], useGeoJSON);
}
else {
Expand All @@ -122,7 +122,7 @@ var getElementById = function(id, context) {
id = id.replace('#', '');

if ('jQuery' in this && context) {
element = $("#" + id, context)[0];
element = $('#' + id, context)[0];
} else {
element = document.getElementById(id);
};
Expand Down Expand Up @@ -157,7 +157,11 @@ var GMaps = (function(global) {

var self = this,
i,
events_that_hide_context_menu = ['bounds_changed', 'center_changed', 'click', 'dblclick', 'drag', 'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed', 'resize', 'tilesloaded', 'zoom_changed'],
events_that_hide_context_menu = [
'bounds_changed', 'center_changed', 'click', 'dblclick', 'drag',
'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed',
'resize', 'tilesloaded', 'zoom_changed'
],
events_that_doesnt_hide_context_menu = ['mousemove', 'mouseout', 'mouseover'],
options_to_be_deleted = ['el', 'lat', 'lng', 'mapType', 'width', 'height', 'markerClusterer', 'enableNewStyle'],
container_id = options.el || options.div,
Expand Down Expand Up @@ -424,10 +428,11 @@ var GMaps = (function(global) {
};

this.fitLatLngBounds = function(latLngs) {
var total = latLngs.length;
var bounds = new google.maps.LatLngBounds();
var total = latLngs.length,
bounds = new google.maps.LatLngBounds(),
i;

for(var i=0; i < total; i++) {
for(i = 0; i < total; i++) {
bounds.extend(latLngs[i]);
}

Expand Down Expand Up @@ -469,7 +474,7 @@ var GMaps = (function(global) {
}
}

for (i=0; i < native_methods.length; i++) {
for (i = 0; i < native_methods.length; i++) {
(function(gmaps, scope, method_name) {
gmaps[method_name] = function(){
return scope[method_name].apply(scope, arguments);
Expand Down Expand Up @@ -532,16 +537,18 @@ GMaps.prototype.createControl = function(options) {

GMaps.prototype.addControl = function(options) {
var control = this.createControl(options);

this.controls.push(control);
this.map.controls[control.position].push(control);

return control;
};

GMaps.prototype.removeControl = function(control) {
var position = null;
var position = null,
i;

for (var i = 0; i < this.controls.length; i++) {
for (i = 0; i < this.controls.length; i++) {
if (this.controls[i] == control) {
position = this.controls[i].position;
this.controls.splice(i, 1);
Expand All @@ -550,9 +557,11 @@ GMaps.prototype.removeControl = function(control) {

if (position) {
for (i = 0; i < this.map.controls.length; i++) {
var controlsForPosition = this.map.controls[control.position]
var controlsForPosition = this.map.controls[control.position];

if (controlsForPosition.getAt(i) == control) {
controlsForPosition.removeAt(i);

break;
}
}
Expand Down Expand Up @@ -916,7 +925,7 @@ GMaps.prototype.drawPolyline = function(options) {
path = points;
}
else {
for (var i=0, latlng; latlng=points[i]; i++) {
for (var i = 0, latlng; latlng = points[i]; i++) {
path.push(new google.maps.LatLng(latlng[0], latlng[1]));
}
}
Expand Down Expand Up @@ -1397,12 +1406,18 @@ GMaps.prototype.drawRoute = function(options) {
error: options.error,
callback: function(e) {
if (e.length > 0) {
self.drawPolyline({
var polyline_options = {
path: e[e.length - 1].overview_path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
};

if (options.hasOwnProperty("icons")) {
polyline_options.icons = options.icons;
}

self.drawPolyline(polyline_options);

if (options.callback) {
options.callback(e[e.length - 1]);
Expand Down Expand Up @@ -1432,7 +1447,7 @@ GMaps.prototype.travelRoute = function(options) {
var route = e[e.length - 1];
if (route.legs.length > 0) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
for (var i = 0, step; step = steps[i]; i++) {
step.step_number = i;
options.step(step, (route.legs[0].steps.length - 1));
}
Expand All @@ -1449,7 +1464,7 @@ GMaps.prototype.travelRoute = function(options) {
else if (options.route) {
if (options.route.legs.length > 0) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
for (var i = 0, step; step = steps[i]; i++) {
step.step_number = i;
options.step(step);
}
Expand Down Expand Up @@ -1478,14 +1493,20 @@ GMaps.prototype.drawSteppedRoute = function(options) {
var route = e[e.length - 1];
if (route.legs.length > 0) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
for (var i = 0, step; step = steps[i]; i++) {
step.step_number = i;
self.drawPolyline({
var polyline_options = {
path: step.path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
};

if (options.hasOwnProperty("icons")) {
polyline_options.icons = options.icons;
}

self.drawPolyline(polyline_options);
options.step(step, (route.legs[0].steps.length - 1));
}
}
Expand All @@ -1501,14 +1522,20 @@ GMaps.prototype.drawSteppedRoute = function(options) {
else if (options.route) {
if (options.route.legs.length > 0) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
for (var i = 0, step; step = steps[i]; i++) {
step.step_number = i;
self.drawPolyline({
var polyline_options = {
path: step.path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
};

if (options.hasOwnProperty("icons")) {
polyline_options.icons = options.icons;
}

self.drawPolyline(polyline_options);
options.step(step);
}
}
Expand All @@ -1526,12 +1553,18 @@ GMaps.Route = function(options) {
this.steps = this.route.legs[0].steps;
this.steps_length = this.steps.length;

this.polyline = this.map.drawPolyline({
var polyline_options = {
path: new google.maps.MVCArray(),
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
}).getPath();
};

if (options.hasOwnProperty("icons")) {
polyline_options.icons = options.icons;
}

this.polyline = this.map.drawPolyline(polyline_options).getPath();
};

GMaps.Route.prototype.getRoute = function(options) {
Expand Down Expand Up @@ -1629,7 +1662,7 @@ GMaps.prototype.toImage = function(options) {
GMaps.staticMapURL = function(options){
var parameters = [],
data,
static_root = 'http://maps.googleapis.com/maps/api/staticmap';
static_root = (location.protocol === 'file:' ? 'http:' : location.protocol ) + '//maps.googleapis.com/maps/api/staticmap';

if (options.url) {
static_root = options.url;
Expand Down Expand Up @@ -1703,7 +1736,7 @@ GMaps.staticMapURL = function(options){
if (markers) {
var marker, loc;

for (var i=0; data=markers[i]; i++) {
for (var i = 0; data = markers[i]; i++) {
marker = [];

if (data.size && data.size !== 'normal') {
Expand Down
10 changes: 7 additions & 3 deletions lib/gmaps.controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@ GMaps.prototype.createControl = function(options) {

GMaps.prototype.addControl = function(options) {
var control = this.createControl(options);

this.controls.push(control);
this.map.controls[control.position].push(control);

return control;
};

GMaps.prototype.removeControl = function(control) {
var position = null;
var position = null,
i;

for (var i = 0; i < this.controls.length; i++) {
for (i = 0; i < this.controls.length; i++) {
if (this.controls[i] == control) {
position = this.controls[i].position;
this.controls.splice(i, 1);
Expand All @@ -67,9 +69,11 @@ GMaps.prototype.removeControl = function(control) {

if (position) {
for (i = 0; i < this.map.controls.length; i++) {
var controlsForPosition = this.map.controls[control.position]
var controlsForPosition = this.map.controls[control.position];

if (controlsForPosition.getAt(i) == control) {
controlsForPosition.removeAt(i);

break;
}
}
Expand Down
19 changes: 12 additions & 7 deletions lib/gmaps.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var arrayToLatLng = function(coords, useGeoJSON) {

for (i = 0; i < coords.length; i++) {
if (!(coords[i] instanceof google.maps.LatLng)) {
if (coords[i].length > 0 && typeof(coords[i][0]) == "object") {
if (coords[i].length > 0 && typeof(coords[i][0]) === "object") {
coords[i] = arrayToLatLng(coords[i], useGeoJSON);
}
else {
Expand All @@ -102,7 +102,7 @@ var getElementById = function(id, context) {
id = id.replace('#', '');

if ('jQuery' in this && context) {
element = $("#" + id, context)[0];
element = $('#' + id, context)[0];
} else {
element = document.getElementById(id);
};
Expand Down Expand Up @@ -137,7 +137,11 @@ var GMaps = (function(global) {

var self = this,
i,
events_that_hide_context_menu = ['bounds_changed', 'center_changed', 'click', 'dblclick', 'drag', 'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed', 'resize', 'tilesloaded', 'zoom_changed'],
events_that_hide_context_menu = [
'bounds_changed', 'center_changed', 'click', 'dblclick', 'drag',
'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed',
'resize', 'tilesloaded', 'zoom_changed'
],
events_that_doesnt_hide_context_menu = ['mousemove', 'mouseout', 'mouseover'],
options_to_be_deleted = ['el', 'lat', 'lng', 'mapType', 'width', 'height', 'markerClusterer', 'enableNewStyle'],
container_id = options.el || options.div,
Expand Down Expand Up @@ -404,10 +408,11 @@ var GMaps = (function(global) {
};

this.fitLatLngBounds = function(latLngs) {
var total = latLngs.length;
var bounds = new google.maps.LatLngBounds();
var total = latLngs.length,
bounds = new google.maps.LatLngBounds(),
i;

for(var i=0; i < total; i++) {
for(i = 0; i < total; i++) {
bounds.extend(latLngs[i]);
}

Expand Down Expand Up @@ -449,7 +454,7 @@ var GMaps = (function(global) {
}
}

for (i=0; i < native_methods.length; i++) {
for (i = 0; i < native_methods.length; i++) {
(function(gmaps, scope, method_name) {
gmaps[method_name] = function(){
return scope[method_name].apply(scope, arguments);
Expand Down
2 changes: 1 addition & 1 deletion lib/gmaps.geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GMaps.prototype.drawPolyline = function(options) {
path = points;
}
else {
for (var i=0, latlng; latlng=points[i]; i++) {
for (var i = 0, latlng; latlng = points[i]; i++) {
path.push(new google.maps.LatLng(latlng[0], latlng[1]));
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/gmaps.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ GMaps.prototype.travelRoute = function(options) {
var route = e[e.length - 1];
if (route.legs.length > 0) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
for (var i = 0, step; step = steps[i]; i++) {
step.step_number = i;
options.step(step, (route.legs[0].steps.length - 1));
}
Expand All @@ -181,7 +181,7 @@ GMaps.prototype.travelRoute = function(options) {
else if (options.route) {
if (options.route.legs.length > 0) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
for (var i = 0, step; step = steps[i]; i++) {
step.step_number = i;
options.step(step);
}
Expand Down Expand Up @@ -210,7 +210,7 @@ GMaps.prototype.drawSteppedRoute = function(options) {
var route = e[e.length - 1];
if (route.legs.length > 0) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
for (var i = 0, step; step = steps[i]; i++) {
step.step_number = i;
var polyline_options = {
path: step.path,
Expand Down Expand Up @@ -239,7 +239,7 @@ GMaps.prototype.drawSteppedRoute = function(options) {
else if (options.route) {
if (options.route.legs.length > 0) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
for (var i = 0, step; step = steps[i]; i++) {
step.step_number = i;
var polyline_options = {
path: step.path,
Expand Down
2 changes: 1 addition & 1 deletion lib/gmaps.static.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ GMaps.staticMapURL = function(options){
if (markers) {
var marker, loc;

for (var i=0; data=markers[i]; i++) {
for (var i = 0; data = markers[i]; i++) {
marker = [];

if (data.size && data.size !== 'normal') {
Expand Down
Loading

0 comments on commit ad937e4

Please sign in to comment.