diff --git a/bower.json b/bower.json index 8c2db1f..f86164a 100644 --- a/bower.json +++ b/bower.json @@ -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", diff --git a/dist/gmap3.js b/dist/gmap3.js index 103ab18..4f9c053 100644 --- a/dist/gmap3.js +++ b/dist/gmap3.js @@ -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 : jbdemonte@gmail.com * 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, @@ -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(), @@ -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); @@ -737,6 +754,14 @@ }, 10); } + /** + * Configure google maps loading library + * @param {string|object} options + */ + $.gmap3 = function (options) { + loadOptions = options; + }; + /** * jQuery Plugin */ @@ -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]; } }; @@ -1100,4 +1128,4 @@ } } -})(jQuery, window); \ No newline at end of file +})(jQuery, window, document); \ No newline at end of file diff --git a/dist/gmap3.min.js b/dist/gmap3.min.js index 5db4152..abb57c9 100644 --- a/dist/gmap3.min.js +++ b/dist/gmap3.min.js @@ -1,10 +1,10 @@ /*! * GMAP3 Plugin for jQuery - * Version : 7.0 - * Date : 2016/03/28 + * Version : 7.1 + * Date : 2016/04/17 * Author : DEMONTE Jean-Baptiste * Contact : jbdemonte@gmail.com * Web site : http://gmap3.net * Licence : GPL-3.0+ */ -!function(n,t){"use strict";function e(n){return E(!0,{},n||{})}function o(){var n=Array.prototype.slice,t=n.call(arguments,1);return n.apply(arguments[0],t)}function r(n){return"undefined"==typeof n}function i(t){return k.apply(n,t)}function u(n){return k().then(function(){return n})}function a(n,t){var e=Math,o=e.PI,r=o*n.lat()/180,i=o*n.lng()/180,u=o*t.lat()/180,a=o*t.lng()/180,c=e.cos,s=e.sin;return 6371e3*e.acos(e.min(c(r)*c(u)*c(i)*c(a)+c(r)*s(i)*c(u)*s(a)+s(r)*s(u),1))}function c(n){return T[n]||(T[n]=s(n)),T[n]}function s(n){function t(n){return e.apply(this,n)}var e=C[n];return t.prototype=e.prototype,new t(o(arguments,1))}function f(n){var t=S();return"string"==typeof n&&(n={address:n}),c("Geocoder").geocode(n,function(n,e){e===C.GeocoderStatus.OK?t.resolve(n[0].geometry.location):t.reject()}),t}function p(n,t){n.split(" ").forEach(t)}function l(n,t){(D(n)?n:[n]).forEach(t)}function g(n){return Object.keys(n)}function d(n){return g(n).map(function(t){return n[t]})}function h(n,t){return n=e(n),n.bounds&&(n.bounds=L(n.bounds)),u(t(n))}function v(n,t,o){var r=S();return n=e(n),k().then(function(){var e=n.address;return e?(delete n.address,f(e).then(function(e){n[t]=e})):void(n[t]=m(n[t]))}).then(function(){r.resolve(o(n))}),r}function y(n,t,o){return n=e(n),n[t]=(n[t]||[]).map(function(n){return m(n)}),u(o(n))}function m(n,t){return D(n)?new C.LatLng(n[0],n[1]):!t||!n||n instanceof C.LatLng?n:new C.LatLng(n.lat,n.lng)}function L(n,t){return D(n)?new C.LatLngBounds({lat:n[2],lng:n[3]},{lat:n[0],lng:n[1]}):t&&!n.getCenter?new C.LatLngBounds({lat:n.south,lng:n.west},{lat:n.north,lng:n.east}):n}function w(t,e){function o(){function n(n){return o.getProjection().fromLatLngToDivPixel(n)}var o=this,u=[];r.call(o),o.setMap(t),o.onAdd=function(){var n=o.getPanes();n.overlayMouseTarget.appendChild(i[0])},e.position?(o.getPosition=function(){return e.position},o.setPosition=function(n){e.position=n,o.draw()},o.draw=function(){var t=n(e.position);i.css({left:t.x+e.x+"px",top:t.y+e.y+"px"})}):(o.getBounds=function(){return e.bounds},o.setBounds=function(n){e.bounds=n,o.draw()},o.draw=function(){var t=n(e.bounds.getSouthWest()),o=n(e.bounds.getNorthEast());i.css({left:t.x+e.x+"px",top:o.y+e.y+"px",width:o.x-t.x+e.x+"px",height:t.y-o.y+e.y+"px"})}),o.onRemove=function(){u.map(function(n){C.event.removeListener(n)}),i.remove(),o.$=i=null},o.$=i}var r=C.OverlayView,i=n(document.createElement("div")).css({border:"none",borderWidth:0,position:"absolute"}).append(e.content);return e=E({x:0,y:0},e),e.position?e.position=m(e.position,!0):e.bounds&&(e.bounds=L(e.bounds,!0)),o.prototype=new r,new o}function x(n){function t(){var n=this;return n.onAdd=n.onRemove=n.draw=function(){},C.OverlayView.call(n)}t.prototype=new C.OverlayView;var e=new t;return e.setMap(n),e.getProjection()}function P(n,t,e,o){var r=this;r.cluster=n,r.markers=t,r.$=e.$,r.overlay=e,e.getBounds=function(){return s("LatLngBounds",o.getSouthWest(),o.getNorthEast())}}function b(n,t){function r(){var t=s("Circle",{center:n.getCenter(),radius:1.15*a(n.getCenter(),n.getBounds().getNorthEast())});return t.getBounds()}function i(n){var t=y.fromLatLngToDivPixel(n);return s("LatLngBounds",y.fromDivPixelToLatLng(s("Point",t.x-B,t.y+B)),y.fromDivPixelToLatLng(s("Point",t.x+B,t.y-B)))}function u(){var u,a,c,f,p,d,h=n.getZoom(),y={},m=[],x={};d=""+h,h>3&&(a=r(),l(M,function(n,t){a.contains(n.getPosition())||(d+="-"+t,x[t]=!0,n.getMap()&&n.setMap(null))})),L&&l(M,function(n,t){x[t]||L(n)||(d+="-"+t,x[t]=!0,n.getMap()&&n.setMap(null))}),d!==v&&(v=d,l(M,function(r,g){x[g]||(u=[g],a=i(r.getPosition()),T&&l(o(M,g+1),function(n,t){t+=g+1,!x[t]&&a.contains(n.getPosition())&&(u.push(t),x[t]=!0)}),f=u.join("-"),y[f]=!0,k[f]||(p=u.map(function(n){return M[n]}),c=t.cb(o(p)),c?(a=s("LatLngBounds"),l(p,function(n){a.extend(n.getPosition()),n.getMap()&&n.setMap(null)}),c=e(c),c.position=a.getCenter(),k[f]=new P(b,o(p),w(n,c),a),m.push(k[f])):l(p,function(t){t.getMap()||t.setMap(n)})))}),l(g(k),function(n){y[n]||(k[n].overlay.setMap(null),delete k[n])}),m.length&&l(E,function(n){n(m)}))}function c(){clearTimeout(p),p=setTimeout(u,100)}function f(){C.event.addListener(n,"zoom_changed",c),C.event.addListener(n,"bounds_changed",c),u()}var p,h,v,y,L,b=this,M=[],B=(t.size||200)>>1,T=!0,k={},E=[];t=t||{},t.markers=t.markers||[],b._b=function(n){n(d(k)),E.push(n)},b.markers=function(){return o(M)},b.groups=function(){return d(k)},b.enable=function(){T||(T=!0,v="",c())},b.disable=function(){T&&(T=!1,v="",c())},b.add=function(n){M.push(n),v="",c()},b.remove=function(n){M=M.filter(function(t){return t!==n}),v="",c()},b.filter=function(n){L!==n&&(L=n,v="",c())},t.markers.map(function(n){n.position=m(n.position),M.push(s("Marker",n))}),h=setInterval(function(){y=x(n),y&&(clearInterval(h),f())},10)}function M(n,t){var e=this;g(t[0]).forEach(function(n){e[n]=function(){var r=[],i=o(arguments);return t.forEach(function(t){r.push(t[n].apply(t,i))}),"get"===n?r.length>1?r:r[0]:e}}),e.$=n}function B(t,a){function f(){return{$:t,get:T.get}}function g(t,e,r,i){var u=arguments.length>3;u||(i=r),n.each(t,function(n,t){l(e,function(e){var a=e instanceof P,c=a||e instanceof C.OverlayView,s=c?e.$.get(0):e;C.event["add"+(c?"Dom":"")+"Listener"+(i?"Once":"")](s,n,function(n){l(t,function(t){if(O(t))if(a)t.call(f(),void 0,e,e.cluster,n);else if(u){var i=o(r);i.unshift(e),i.push(n),t.apply(f(),i)}else t.call(f(),e,n)})})})})}function d(n){return function(t){if(D(t)){var e=[],o=t.map(function(t){return n.call(T,t).then(function(n){e.push(n)})});return i(o).then(function(){return M.push(e),e})}return n.apply(T,arguments).then(function(n){return M.push(n),n})}}function L(n){return function(){var t=o(arguments);return B=B.then(function(e){return O(t[0])?k(t[0].call(f(),e)).then(function(e){return t[0]=e,n.apply(T,t)}):k(n.apply(T,t))})}}var x,M=[],B=k(),T=this;T.map=L(function(n){return x||v(n,"center",function(n){return x=s("Map",t.get(0),n),M.push(x),x})}),p("Marker:position Circle:center InfoWindow:position:0 Polyline:path Polygon:paths",function(n){n=n.split(":");var t=n[1]||"";T[n[0].toLowerCase()]=L(d(function(e){return(t.match(/^path/)?y:v)(e,t,function(t){return"0"!==n[2]&&(t.map=x),s(n[0],t)})}))}),p("TrafficLayer TransitLayer BicyclingLayer",function(n){T[n.toLowerCase()]=L(function(){var t=s(n);return M.push(t),t.setMap(x),t})}),T.kmllayer=L(d(function(n){return n=e(n),n.map=x,k(s("KmlLayer",n))})),T.rectangle=L(d(function(n){return h(n,function(n){return n.map=x,s("Rectangle",n)})})),T.overlay=L(d(function(n){function t(n){return w(x,n)}return n=e(n),n.bounds?h(n,t):v(n,"position",t)})),T.groundoverlay=L(function(n,t,o){return h({bounds:t},function(t){o=e(o),o.map=x;var r=s("GroundOverlay",n,t.bounds,o);return M.push(r),r})}),T.styledmaptype=L(function(n,t,e){var o=s("StyledMapType",t,e);return M.push(o),x.mapTypes.set(n,o),o}),T.streetviewpanorama=L(function(t,e){return v(e,"position",function(e){var o=s("StreetViewPanorama",n(t).get(0),e);return x.setStreetView(o),M.push(o),o})}),T.route=L(function(n){var t=S();return n=e(n),n.origin=m(n.origin),n.destination=m(n.destination),c("DirectionsService").route(n,function(n,e){M.push(n),t.resolve(e===C.DirectionsStatus.OK?n:!1)}),t}),T.cluster=L(function(n){var t=new b(x,e(n));return M.push(t),u(t)}),T.directionsrenderer=L(function(t){var o;return t&&(t=e(t),t.map=x,t.panel&&(t.panel=n(t.panel).get(0)),o=s("DirectionsRenderer",t)),M.push(o),o}),T.latlng=L(d(function(n){return v(n,"latlng",function(n){return M.push(n.latlng),n.latlng})})),T.fit=L(function(){var n=s("LatLngBounds");return l(M,function(t){t!==x&&l(t,function(t){t&&(t.getPosition&&t.getPosition()?n.extend(t.getPosition()):t.getBounds&&t.getBounds()?(n.extend(t.getBounds().getNorthEast()),n.extend(t.getBounds().getSouthWest())):t.getPaths&&t.getPaths()?l(t.getPaths().getArray(),function(t){l(t.getArray(),function(t){n.extend(t)})}):t.getPath&&t.getPath()?l(t.getPath().getArray(),function(t){n.extend(t)}):t.getCenter&&t.getCenter()&&n.extend(t.getCenter()))})}),n.isEmpty()||x.fitBounds(n),!0}),T.wait=function(n){B=B.then(function(t){var e=S();return setTimeout(function(){e.resolve(t)},n),e})},T.then=function(n){O(n)&&(B=B.then(function(t){return k(n.call(f(),t)).then(function(n){return r(n)?t:n})}))},p("on once",function(n,t){T[n]=function(){var n=arguments[0];n&&("string"==typeof n&&(n={},n[arguments[0]]=o(arguments,1)),B.then(function(e){if(e){if(e instanceof b)return e._b(function(e){e&&e.length&&g(n,e,t)}),g(n,e.markers(),[void 0,e],t);g(n,e,t)}}))}}),T.get=function(n){return r(n)?M.map(function(n){return D(n)?n.slice():n}):D(M[n])?M[n].slice():M[n]},a&&T.map(a)}var C,T={},k=n.when,E=n.extend,D=n.isArray,O=n.isFunction,S=n.Deferred;(function(){var e,o=S(),r="__gmap3";return n.holdReady(!0),t.google&&t.google.maps?o.resolve():(t[r]=function(){delete t[r],o.resolve()},e=t.document.createElement("script"),e.type="text/javascript",e.src="https://maps.googleapis.com/maps/api/js?callback="+r,n("head").append(e)),o.promise()})().then(function(){n.holdReady(!1)}),n.fn.gmap3=function(e){var o=[];return C=t.google.maps,this.each(function(){var t=n(this),r=t.data("gmap3");r||(r=new B(t,e),t.data("gmap3",r)),o.push(r)}),new M(this,o)}}(jQuery,window); \ No newline at end of file +!function(n,t,e){"use strict";function o(n){return j(!0,{},n||{})}function r(){var n=Array.prototype.slice,t=n.call(arguments,1);return n.apply(arguments[0],t)}function i(n){return"undefined"==typeof n}function u(t){return S.apply(n,t)}function a(n){return S().then(function(){return n})}function c(n,t){var e=Math,o=e.PI,r=o*n.lat()/180,i=o*n.lng()/180,u=o*t.lat()/180,a=o*t.lng()/180,c=e.cos,s=e.sin;return 6371e3*e.acos(e.min(c(r)*c(u)*c(i)*c(a)+c(r)*s(i)*c(u)*s(a)+s(r)*s(u),1))}function s(n){"loading"!=e.readyState?n():e.addEventListener("DOMContentLoaded",n)}function f(n){return v(n).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(n[t])}).join("&")}function p(n){return O[n]||(O[n]=l(n)),O[n]}function l(n){function t(n){return e.apply(this,n)}var e=k[n];return t.prototype=e.prototype,new t(r(arguments,1))}function g(n){var t=$();return"string"==typeof n&&(n={address:n}),p("Geocoder").geocode(n,function(n,e){e===k.GeocoderStatus.OK?t.resolve(n[0].geometry.location):t.reject()}),t}function d(n,t){n.split(" ").forEach(t)}function h(n,t){(R(n)?n:[n]).forEach(t)}function v(n){return Object.keys(n)}function y(n){return v(n).map(function(t){return n[t]})}function m(n,t){return n=o(n),n.bounds&&(n.bounds=P(n.bounds)),a(t(n))}function L(n,t,e){var r=$();return n=o(n),S().then(function(){var e=n.address;return e?(delete n.address,g(e).then(function(e){n[t]=e})):void(n[t]=x(n[t]))}).then(function(){r.resolve(e(n))}),r}function w(n,t,e){return n=o(n),n[t]=(n[t]||[]).map(function(n){return x(n)}),a(e(n))}function x(n,t){return R(n)?new k.LatLng(n[0],n[1]):!t||!n||n instanceof k.LatLng?n:new k.LatLng(n.lat,n.lng)}function P(n,t){return R(n)?new k.LatLngBounds({lat:n[2],lng:n[3]},{lat:n[0],lng:n[1]}):t&&!n.getCenter?new k.LatLngBounds({lat:n.south,lng:n.west},{lat:n.north,lng:n.east}):n}function b(t,o){function r(){function n(n){return e.getProjection().fromLatLngToDivPixel(n)}var e=this,r=[];i.call(e),e.setMap(t),e.onAdd=function(){var n=e.getPanes();n.overlayMouseTarget.appendChild(u[0])},o.position?(e.getPosition=function(){return o.position},e.setPosition=function(n){o.position=n,e.draw()},e.draw=function(){var t=n(o.position);u.css({left:t.x+o.x+"px",top:t.y+o.y+"px"})}):(e.getBounds=function(){return o.bounds},e.setBounds=function(n){o.bounds=n,e.draw()},e.draw=function(){var t=n(o.bounds.getSouthWest()),e=n(o.bounds.getNorthEast());u.css({left:t.x+o.x+"px",top:e.y+o.y+"px",width:e.x-t.x+o.x+"px",height:t.y-e.y+o.y+"px"})}),e.onRemove=function(){r.map(function(n){k.event.removeListener(n)}),u.remove(),e.$=u=null},e.$=u}var i=k.OverlayView,u=n(e.createElement("div")).css({border:"none",borderWidth:0,position:"absolute"}).append(o.content);return o=j({x:0,y:0},o),o.position?o.position=x(o.position,!0):o.bounds&&(o.bounds=P(o.bounds,!0)),r.prototype=new i,new r}function M(n){function t(){var n=this;return n.onAdd=n.onRemove=n.draw=function(){},k.OverlayView.call(n)}t.prototype=new k.OverlayView;var e=new t;return e.setMap(n),e.getProjection()}function B(n,t,e,o){var r=this;r.cluster=n,r.markers=t,r.$=e.$,r.overlay=e,e.getBounds=function(){return l("LatLngBounds",o.getSouthWest(),o.getNorthEast())}}function C(n,t){function e(){var t=l("Circle",{center:n.getCenter(),radius:1.15*c(n.getCenter(),n.getBounds().getNorthEast())});return t.getBounds()}function i(n){var t=d.fromLatLngToDivPixel(n);return l("LatLngBounds",d.fromDivPixelToLatLng(l("Point",t.x-P,t.y+P)),d.fromDivPixelToLatLng(l("Point",t.x+P,t.y-P)))}function u(){var u,a,c,s,f,p,d=n.getZoom(),y={},x=[],P={};p=""+d,d>3&&(a=e(),h(w,function(n,t){a.contains(n.getPosition())||(p+="-"+t,P[t]=!0,n.getMap()&&n.setMap(null))})),m&&h(w,function(n,t){P[t]||m(n)||(p+="-"+t,P[t]=!0,n.getMap()&&n.setMap(null))}),p!==g&&(g=p,h(w,function(e,p){P[p]||(u=[p],a=i(e.getPosition()),C&&h(r(w,p+1),function(n,t){t+=p+1,!P[t]&&a.contains(n.getPosition())&&(u.push(t),P[t]=!0)}),s=u.join("-"),y[s]=!0,E[s]||(f=u.map(function(n){return w[n]}),c=t.cb(r(f)),c?(a=l("LatLngBounds"),h(f,function(n){a.extend(n.getPosition()),n.getMap()&&n.setMap(null)}),c=o(c),c.position=a.getCenter(),E[s]=new B(L,r(f),b(n,c),a),x.push(E[s])):h(f,function(t){t.getMap()||t.setMap(n)})))}),h(v(E),function(n){y[n]||(E[n].overlay.setMap(null),delete E[n])}),x.length&&h(T,function(n){n(x)}))}function a(){clearTimeout(f),f=setTimeout(u,100)}function s(){k.event.addListener(n,"zoom_changed",a),k.event.addListener(n,"bounds_changed",a),u()}var f,p,g,d,m,L=this,w=[],P=(t.size||200)>>1,C=!0,E={},T=[];t=t||{},t.markers=t.markers||[],L._b=function(n){n(y(E)),T.push(n)},L.markers=function(){return r(w)},L.groups=function(){return y(E)},L.enable=function(){C||(C=!0,g="",a())},L.disable=function(){C&&(C=!1,g="",a())},L.add=function(n){w.push(n),g="",a()},L.remove=function(n){w=w.filter(function(t){return t!==n}),g="",a()},L.filter=function(n){m!==n&&(m=n,g="",a())},t.markers.map(function(n){n.position=x(n.position),w.push(l("Marker",n))}),p=setInterval(function(){d=M(n),d&&(clearInterval(p),s())},10)}function E(n,t){var e=this;v(t[0]).forEach(function(n){e[n]=function(){var o=[],i=r(arguments);return t.forEach(function(t){o.push(t[n].apply(t,i))}),"get"===n?o.length>1?o:o[0]:e}}),e.$=n}function T(t,e){function c(){return{$:t,get:M.get}}function s(t,e,o,i){var u=arguments.length>3;u||(i=o),n.each(t,function(n,t){h(e,function(e){var a=e instanceof B,s=a||e instanceof k.OverlayView,f=s?e.$.get(0):e;k.event["add"+(s?"Dom":"")+"Listener"+(i?"Once":"")](f,n,function(n){h(t,function(t){if(A(t))if(a)t.call(c(),void 0,e,e.cluster,n);else if(u){var i=r(o);i.unshift(e),i.push(n),t.apply(c(),i)}else t.call(c(),e,n)})})})})}function f(n){return function(t){if(R(t)){var e=[],o=t.map(function(t){return n.call(M,t).then(function(n){e.push(n)})});return u(o).then(function(){return y.push(e),e})}return n.apply(M,arguments).then(function(n){return y.push(n),n})}}function g(n){return function(){var t=r(arguments);return P=P.then(function(e){return A(t[0])?S(t[0].call(c(),e)).then(function(e){return t[0]=e,n.apply(M,t)}):S(n.apply(M,t))})}}var v,y=[],P=S(),M=this;M.map=g(function(n){return v||L(n,"center",function(n){return v=l("Map",t.get(0),n),y.push(v),v})}),d("Marker:position Circle:center InfoWindow:position:0 Polyline:path Polygon:paths",function(n){n=n.split(":");var t=n[1]||"";M[n[0].toLowerCase()]=g(f(function(e){return(t.match(/^path/)?w:L)(e,t,function(t){return"0"!==n[2]&&(t.map=v),l(n[0],t)})}))}),d("TrafficLayer TransitLayer BicyclingLayer",function(n){M[n.toLowerCase()]=g(function(){var t=l(n);return y.push(t),t.setMap(v),t})}),M.kmllayer=g(f(function(n){return n=o(n),n.map=v,S(l("KmlLayer",n))})),M.rectangle=g(f(function(n){return m(n,function(n){return n.map=v,l("Rectangle",n)})})),M.overlay=g(f(function(n){function t(n){return b(v,n)}return n=o(n),n.bounds?m(n,t):L(n,"position",t)})),M.groundoverlay=g(function(n,t,e){return m({bounds:t},function(t){e=o(e),e.map=v;var r=l("GroundOverlay",n,t.bounds,e);return y.push(r),r})}),M.styledmaptype=g(function(n,t,e){var o=l("StyledMapType",t,e);return y.push(o),v.mapTypes.set(n,o),o}),M.streetviewpanorama=g(function(t,e){return L(e,"position",function(e){var o=l("StreetViewPanorama",n(t).get(0),e);return v.setStreetView(o),y.push(o),o})}),M.route=g(function(n){var t=$();return n=o(n),n.origin=x(n.origin),n.destination=x(n.destination),p("DirectionsService").route(n,function(n,e){y.push(n),t.resolve(e===k.DirectionsStatus.OK?n:!1)}),t}),M.cluster=g(function(n){var t=new C(v,o(n));return y.push(t),a(t)}),M.directionsrenderer=g(function(t){var e;return t&&(t=o(t),t.map=v,t.panel&&(t.panel=n(t.panel).get(0)),e=l("DirectionsRenderer",t)),y.push(e),e}),M.latlng=g(f(function(n){return L(n,"latlng",function(n){return y.push(n.latlng),n.latlng})})),M.fit=g(function(){var n=l("LatLngBounds");return h(y,function(t){t!==v&&h(t,function(t){t&&(t.getPosition&&t.getPosition()?n.extend(t.getPosition()):t.getBounds&&t.getBounds()?(n.extend(t.getBounds().getNorthEast()),n.extend(t.getBounds().getSouthWest())):t.getPaths&&t.getPaths()?h(t.getPaths().getArray(),function(t){h(t.getArray(),function(t){n.extend(t)})}):t.getPath&&t.getPath()?h(t.getPath().getArray(),function(t){n.extend(t)}):t.getCenter&&t.getCenter()&&n.extend(t.getCenter()))})}),n.isEmpty()||v.fitBounds(n),!0}),M.wait=function(n){P=P.then(function(t){var e=$();return setTimeout(function(){e.resolve(t)},n),e})},M.then=function(n){A(n)&&(P=P.then(function(t){return S(n.call(c(),t)).then(function(n){return i(n)?t:n})}))},d("on once",function(n,t){M[n]=function(){var n=arguments[0];n&&("string"==typeof n&&(n={},n[arguments[0]]=r(arguments,1)),P.then(function(e){if(e){if(e instanceof C)return e._b(function(e){e&&e.length&&s(n,e,t)}),s(n,e.markers(),[void 0,e],t);s(n,e,t)}}))}}),M.get=function(n){return i(n)?y.map(function(n){return R(n)?n.slice():n}):(0>n&&(n=y.length+n),R(y[n])?y[n].slice():y[n])},e&&M.map(e)}var k,D,O={},S=n.when,j=n.extend,R=n.isArray,A=n.isFunction,$=n.Deferred;(function(){var o,r=$(),i="__gmap3";return n.holdReady(!0),s(function(){t.google&&t.google.maps||D===!1?r.resolve():(t[i]=function(){delete t[i],r.resolve()},o=e.createElement("script"),o.type="text/javascript",o.src="https://maps.googleapis.com/maps/api/js?callback="+i+(D?"&"+("string"==typeof D?D:f(D)):""),n("head").append(o))}),r.promise()})().then(function(){n.holdReady(!1)}),n.gmap3=function(n){D=n},n.fn.gmap3=function(e){var o=[];return k=t.google.maps,this.each(function(){var t=n(this),r=t.data("gmap3");r||(r=new T(t,e),t.data("gmap3",r)),o.push(r)}),new E(this,o)}}(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index 9261895..6e7a826 100644 --- a/package.json +++ b/package.json @@ -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", "homepage": "http://gmap3.net", "main": "dist/gmap3.min.js", diff --git a/src/gmap3.js b/src/gmap3.js index 9e73f65..4f9c053 100644 --- a/src/gmap3.js +++ b/src/gmap3.js @@ -1,7 +1,7 @@ /*! * GMAP3 Plugin for jQuery - * Version : 7.0 - * Date : 2016/03/28 + * Version : 7.1 + * Date : 2016/04/17 * Author : DEMONTE Jean-Baptiste * Contact : jbdemonte@gmail.com * Web site : http://gmap3.net