Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
version 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdemonte committed Apr 17, 2016
1 parent fcf1bfa commit 0f715fd
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 27 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gmap3",
"version": "7.0.0",
"date": "2016-03-28",
"version": "7.1.0",
"date": "2016-04-17",
"description": "jQuery plugin to generate Google Maps",
"author": {
"name": "Jean-Baptiste DEMONTE",
Expand Down
64 changes: 46 additions & 18 deletions dist/gmap3.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*!
* GMAP3 Plugin for jQuery
* Version : 7.0
* Date : 2016/03/28
* Version : 7.1
* Date : 2016/04/17
* Author : DEMONTE Jean-Baptiste
* Contact : [email protected]
* Web site : http://gmap3.net
* Licence : GPL-3.0+
*/
(function ($, window) {
(function ($, window, document) {
"use strict";

var gm, services = {},
var gm, services = {}, loadOptions,

// Proxify functions to get shorter minimized code
// Proxify functions to get shorter minimized code
when = $.when,
extend = $.extend,
isArray = $.isArray,
Expand Down Expand Up @@ -88,6 +88,20 @@
return 1000 * 6371 * m.acos(m.min(cos(e) * cos(g) * cos(f) * cos(h) + cos(e) * sin(f) * cos(g) * sin(h) + sin(e) * sin(g), 1));
}

function ready(fn) {
if (document.readyState != 'loading'){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}

function serialize(obj) {
return objectKeys(obj).map(function (key) {
return encodeURIComponent(key) + "=" + encodeURIComponent(obj[key]);
}).join("&");
}

// Auto-load google maps library if needed
(function () {
var dfd = deferred(),
Expand All @@ -96,19 +110,22 @@

$.holdReady(true);

if (window.google && window.google.maps) {
dfd.resolve();
} else {
// callback function - resolving promise after maps successfully loaded
window[cbName] = function () {
delete window[cbName];
ready(function () {
if (window.google && window.google.maps || loadOptions === false) {
dfd.resolve();
};
script = window.document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?callback=' + cbName;
$("head").append(script);
}
} else {
// callback function - resolving promise after maps successfully loaded
window[cbName] = function () {
delete window[cbName];
dfd.resolve();
};
script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?callback=' + cbName + (loadOptions ? '&' + (typeof loadOptions === 'string' ? loadOptions : serialize(loadOptions)) : '');
$("head").append(script);
}
});

return dfd.promise();
})().then(function () {
$.holdReady(false);
Expand Down Expand Up @@ -737,6 +754,14 @@
}, 10);
}

/**
* Configure google maps loading library
* @param {string|object} options
*/
$.gmap3 = function (options) {
loadOptions = options;
};

/**
* jQuery Plugin
*/
Expand Down Expand Up @@ -1091,6 +1116,9 @@
return isArray(instance) ? instance.slice() : instance;
});
} else {
if (index < 0) {
index = previousResults.length + index;
}
return isArray(previousResults[index]) ? previousResults[index].slice() : previousResults[index];
}
};
Expand All @@ -1100,4 +1128,4 @@
}
}

})(jQuery, window);
})(jQuery, window, document);
Loading

0 comments on commit 0f715fd

Please sign in to comment.