Permalink
Browse files

update to gmap 4.1

  • Loading branch information...
1 parent a927150 commit c6dfe69a6e8afc924f5657cb298a8ca6d955dbc9 @ianare ianare committed May 28, 2012
Showing with 185 additions and 125 deletions.
  1. +181 −96 jquery-gmap/assets/gmap3.js
  2. +4 −29 jquery-gmap/assets/gmap3.min.js
View
277 jquery-gmap/assets/gmap3.js
@@ -1,7 +1,7 @@
/*
* GMAP3 Plugin for JQuery
- * Version : 4.0
- * Date : 2011-08-23
+ * Version : 4.1
+ * Date : 2011-11-18
* Licence : GPL v3 : http://www.gnu.org/licenses/gpl.html
* Author : DEMONTE Jean-Baptiste
* Contact : jbdemonte@gmail.com
@@ -386,7 +386,7 @@
return markers[i];
}
- this.clusters = function(map, radius, force){
+ this.clusters = function(map, radius, maxZoom, force){
var proj = map.getProjection(),
nwP = proj.fromLatLngToPoint(
new google.maps.LatLng(
@@ -403,12 +403,14 @@
cluster,
chk,
lat, lng, keys, cnt,
- bounds = map.getBounds();
+ bounds = map.getBounds(),
+ noClusters = maxZoom && (maxZoom <= map.getZoom()),
+ chkContain = map.getZoom() > 2;
cnt = 0;
keys = {};
for(i = 0; i < markers.length; i++){
- if (!bounds.contains(markers[i].latLng)){
+ if (chkContain && !bounds.contains(markers[i].latLng)){
continue;
}
p = proj.fromLatLngToPoint(markers[i].latLng);
@@ -420,7 +422,7 @@
cnt++;
}
// check if visible markers have changed
- if (!force){
+ if (!force && !noClusters){
for(k = 0; k < latest.length; k++){
if( k in keys ){
cnt--;
@@ -466,44 +468,49 @@
lng = pos[i][1];
saved = null;
- do{
- cluster = {lat:0, lng:0, idx:[]};
- for(k2 = k; k2<keys.length; k2++){
- if (!(keys[k2] in unik)){
- continue;
+
+ if (noClusters){
+ saved = {lat:lat, lng:lng, idx:[i]};
+ } else {
+ do{
+ cluster = {lat:0, lng:0, idx:[]};
+ for(k2 = k; k2<keys.length; k2++){
+ if (!(keys[k2] in unik)){
+ continue;
+ }
+ j = keys[k2];
+ if ( Math.pow(lat - pos[j][0], 2) + Math.pow(lng-pos[j][1], 2) <= radius ){
+ for(j2 in unik[j]){
+ cluster.lat += markers[j2].latLng.lat();
+ cluster.lng += markers[j2].latLng.lng();
+ cluster.idx.push(j2);
+ }
+ }
}
- j = keys[k2];
- if ( Math.pow(lat - pos[j][0], 2) + Math.pow(lng-pos[j][1], 2) <= radius ){
- for(j2 in unik[j]){
- cluster.lat += markers[j2].latLng.lat();
- cluster.lng += markers[j2].latLng.lng();
- cluster.idx.push(j2);
+ cluster.lat /= cluster.idx.length;
+ cluster.lng /= cluster.idx.length;
+ if (!saved){
+ chk = cluster.idx.length > 1;
+ saved = cluster;
+ } else {
+ chk = cluster.idx.length > saved.idx.length;
+ if (chk){
+ saved = cluster;
}
}
- }
- cluster.lat /= cluster.idx.length;
- cluster.lng /= cluster.idx.length;
- if (!saved){
- chk = cluster.idx.length > 1;
- saved = cluster;
- } else {
- chk = cluster.idx.length > saved.idx.length;
if (chk){
- saved = cluster;
+ p = proj.fromLatLngToPoint( new google.maps.LatLng(saved.lat, saved.lng) );
+ lat = Math.floor((p.x - nwP.x) * Math.pow(2, z));
+ lng = Math.floor((p.y - nwP.y) * Math.pow(2, z));
}
- }
- if (chk){
- p = proj.fromLatLngToPoint( new google.maps.LatLng(saved.lat, saved.lng) );
- lat = Math.floor((p.x - nwP.x) * Math.pow(2, z));
- lng = Math.floor((p.y - nwP.y) * Math.pow(2, z));
- }
- } while(chk);
+ } while(chk);
+ }
- for(k2 = 0; k2 < saved.idx.length; k2++){
+ for(k2 = 0; k2 < saved.idx.length; k2++){
if (saved.idx[k2] in unik){
delete(unik[saved.idx[k2]]);
}
- }
+ }
clusters.push(saved);
}
return clusters;
@@ -522,33 +529,7 @@
/* GMAP3 GLOBALS */
/***************************************************************************/
- var _default = {
- verbose:false,
- queryLimit:{
- attempt:5,
- delay:250, // setTimeout(..., delay + random);
- random:250
- },
- init:{
- mapTypeId : google.maps.MapTypeId.ROADMAP,
- center:[46.578498,2.457275],
- zoom: 2
- },
- classes:{
- Map : google.maps.Map,
- Marker : google.maps.Marker,
- InfoWindow : google.maps.InfoWindow,
- Circle : google.maps.Circle,
- Rectangle : google.maps.Rectangle,
- OverlayView : google.maps.OverlayView,
- StreetViewPanorama: google.maps.StreetViewPanorama,
- KmlLayer : google.maps.KmlLayer,
- TrafficLayer : google.maps.TrafficLayer,
- BicyclingLayer : google.maps.BicyclingLayer,
- GroundOverlay : google.maps.GroundOverlay,
- StyledMapType : google.maps.StyledMapType
- }
- },
+ var _default = {},
_properties = ['events','onces','options','apply', 'callback', 'data', 'tag'],
_noInit = ['init', 'geolatlng', 'getlatlng', 'getroute', 'getelevation', 'getdistance', 'addstyledmap', 'setdefault', 'destroy'],
_directs = ['get'],
@@ -946,14 +927,14 @@
}
}
-
/**
- * returns the geographical coordinates from an address and call internal method
+ * returns the geographical coordinates from an address and call internal or given method
**/
this._resolveLatLng = function(todo, method, all, attempt){
var address = ival(todo, 'address'),
params,
- that = this;
+ that = this,
+ fnc = typeof(method) === 'function' ? method : that[method];
if ( address ){
if (!attempt){ // convert undefined to int
attempt = 0;
@@ -967,7 +948,7 @@
params,
function(results, status) {
if (status === google.maps.GeocoderStatus.OK){
- that[method](todo, all ? results : results[0].geometry.location);
+ fnc.apply(that, [todo, all ? results : results[0].geometry.location]);
} else if ( (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) && (attempt < _default.queryLimit.attempt) ){
setTimeout(function(){
that._resolveLatLng(todo, method, all, attempt+1);
@@ -978,14 +959,41 @@
if (_default.verbose){
alert('Geocode error : ' + status);
}
- that[method](todo, false);
+ fnc.apply(that, [todo, false]);;
}
}
);
} else {
- that[method](todo, toLatLng(todo, false, true));
+ fnc.apply(that, [todo, toLatLng(todo, false, true)]);
}
- },
+ }
+
+ /**
+ * returns the geographical coordinates from an array of object using "address" and call internal method
+ **/
+ this._resolveAllLatLng = function(todo, property, method){
+ var that = this,
+ i = -1,
+ solveNext = function(){
+ do{
+ i++;
+ }while( (i < todo[property].length) && !('address' in todo[property][i]) );
+ if (i < todo[property].length){
+ (function(todo){
+ that._resolveLatLng(
+ todo,
+ function(todo, latLng){
+ todo.latLng = latLng;
+ solveNext.apply(that, []); // solve next or execute exit method
+ }
+ );
+ })(todo[property][i]);
+ } else {
+ that[method](todo);
+ }
+ };
+ solveNext();
+ }
/**
* call a function of framework or google map object of the instance
@@ -1129,15 +1137,15 @@
if (map){
delete map;
}
- this._callback($this, null, todo);
+ this._callback(null, todo);
this._end();
}
/**
* Initialize google.maps.Map object
**/
this.init = function(todo, internal){
- var o, k;
+ var o, k, opts;
if (map) { // already initialized
return this._end();
}
@@ -1177,28 +1185,46 @@
/**
* returns address from latlng
**/
- this.getaddress = function(todo){
+ this.getaddress = function(todo, attempt){
var latLng = toLatLng(todo, false, true),
address = ival(todo, 'address'),
params = latLng ? {latLng:latLng} : ( address ? (typeof(address) === 'string' ? {address:address} : address) : null),
- callback = ival(todo, 'callback');
+ callback = ival(todo, 'callback'),
+ that = this;
+ if (!attempt){ // convert undefined to int
+ attempt = 0;
+ }
if (params && typeof(callback) === 'function') {
getGeocoder().geocode(
params,
function(results, status) {
- var out = status === google.maps.GeocoderStatus.OK ? results : false;
- callback.apply($this, [out, status]);
- }
+ if ( (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) && (attempt < _default.queryLimit.attempt) ){
+ setTimeout(function(){
+ that.getaddress(todo, attempt+1);
+ },
+ _default.queryLimit.delay + Math.floor(Math.random() * _default.queryLimit.random)
+ );
+ } else {
+ var out = status === google.maps.GeocoderStatus.OK ? results : false;
+ callback.apply($this, [out, status]);
+ if (!out && _default.verbose){
+ alert('Geocode error : ' + status);
+ }
+ that._end();
+ }
+ }
);
+ } else {
+ this._end();
}
- this._end();
}
/**
* return a route
**/
this.getroute = function(todo){
- var callback = ival(todo, 'callback');
+ var callback = ival(todo, 'callback'),
+ that = this;
if ( (typeof(callback) === 'function') && todo.options ) {
todo.options.origin = toLatLng(todo.options.origin, true);
todo.options.destination = toLatLng(todo.options.destination, true);
@@ -1207,25 +1233,29 @@
function(results, status) {
var out = status == google.maps.DirectionsStatus.OK ? results : false;
callback.apply($this, [out, status]);
+ that._end();
}
);
+ } else {
+ this._end();
}
- this._end();
}
/**
* return the elevation of a location
**/
this.getelevation = function(todo){
- var fnc, latLng, path, samples, i,
+ var fnc, path, samples, i,
locations = [],
callback = ival(todo, 'callback'),
- latLng = ival(todo, 'latlng');
+ latLng = ival(todo, 'latlng'),
+ that = this;
if (typeof(callback) === 'function'){
fnc = function(results, status){
var out = status === google.maps.ElevationStatus.OK ? results : false;
callback.apply($this, [out, status]);
+ that._end();
};
if (latLng){
locations.push(toLatLng(latLng));
@@ -1252,16 +1282,19 @@
}
}
}
+ } else {
+ this._end();
}
- this._end();
}
/**
* return the distance between an origin and a destination
*
**/
this.getdistance = function(todo){
- var i, callback = ival(todo, 'callback');
+ var i,
+ callback = ival(todo, 'callback'),
+ that = this;
if ( (typeof(callback) === 'function') && todo.options && todo.options.origins && todo.options.destinations ) {
// origins and destinations are array containing one or more address strings and/or google.maps.LatLng objects
todo.options.origins = array(todo.options.origins);
@@ -1277,8 +1310,11 @@
function(results, status) {
var out = status == google.maps.DistanceMatrixStatus.OK ? results : false;
callback.apply($this, [out, status]);
+ that._end();
}
);
+ } else {
+ this._end();
}
}
@@ -1341,9 +1377,9 @@
**/
this.addmarkers = function(todo){
if (ival(todo, 'clusters')){
- this._addclusteredmarkers(todo);
+ this._resolveAllLatLng(todo, 'markers', '_addclusteredmarkers');
} else {
- this._addmarkers(todo);
+ this._resolveAllLatLng(todo, 'markers', '_addmarkers');
}
}
@@ -1402,6 +1438,7 @@
var clusterer, i, latLng, storeId,
that = this,
radius = ival(todo, 'radius'),
+ maxZoom = ival(todo, 'maxZoom'),
markers = ival(todo, 'markers'),
styles = ival(todo, 'clusters');
@@ -1423,19 +1460,19 @@
latLng = toLatLng(markers[i]);
clusterer.add(latLng, markers[i]);
}
- storeId = this._initClusters(todo, clusterer, radius, styles);
+ storeId = this._initClusters(todo, clusterer, radius, maxZoom, styles);
}
this._callback(storeId, todo);
this._end();
}
- this._initClusters = function(todo, clusterer, radius, styles){
+ this._initClusters = function(todo, clusterer, radius, maxZoom, styles){
var that = this;
clusterer.setRedraw(function(force){
- var same, clusters = clusterer.clusters(map, radius, force);
+ var same, clusters = clusterer.clusters(map, radius, maxZoom, force);
if (clusters){
same = clusterer.freeDiff(clusters);
that._displayClusters(todo, clusterer, clusters, same, styles);
@@ -1465,7 +1502,7 @@
this._displayClusters = function(todo, clusterer, clusters, same, styles){
var k, i, ii, m, done, obj, shadow, cluster, options, tmp, w, h,
- atodo,
+ atodo, offset,
ctodo = hasKey(todo, 'cluster') ? getObject('', ival(todo, 'cluster')) : {},
mtodo = hasKey(todo, 'marker') ? getObject('', ival(todo, 'marker')) : {};
for(i=0; i<clusters.length; i++){
@@ -1485,6 +1522,7 @@
if (styles[m]){ // cluster defined for the current markers count
w = ival(styles[m], 'width');
h = ival(styles[m], 'height');
+ offset = ival(styles[m], 'offset') || [-w/2, -h/2];
// create a custom _addOverlay command
atodo = {};
@@ -1496,8 +1534,8 @@
pane: 'overlayLayer',
content:styles[m].content.replace('CLUSTER_COUNT', cluster.idx.length),
offset:{
- x: -w/2,
- y: -h/2
+ x: offset[0],
+ y: offset[1]
}
}
}
@@ -1795,7 +1833,6 @@
**/
this.adddirectionsrenderer = function(todo, internal){
var dr, o = getObject('directionrenderer', todo, 'panelId');
- store.rm('directionrenderer');
o.options.map = map;
dr = new google.maps.DirectionsRenderer(o.options);
if (o.panelId) {
@@ -2021,17 +2058,20 @@
}
this._getMaxZoom = function(todo, latLng){
- var callback = ival(todo, 'callback');
+ var callback = ival(todo, 'callback'),
+ that = this;
if (callback && typeof(callback) === 'function') {
getMaxZoomService().getMaxZoomAtLatLng(
latLng,
function(result) {
var zoom = result.status === google.maps.MaxZoomStatus.OK ? result.zoom : false;
callback.apply($this, [zoom, result.status]);
+ that._end();
}
);
+ } else {
+ this._end();
}
- this._end();
}
/**
@@ -2048,7 +2088,8 @@
this.autofit = function(todo, internal){
var names, list, obj, i, j,
empty = true,
- bounds = new google.maps.LatLngBounds();
+ bounds = new google.maps.LatLngBounds(),
+ maxZoom = ival(todo, 'maxZoom', null);
names = store.names();
for(i=0; i<names.length; i++){
@@ -2080,7 +2121,20 @@
}
}
}
- if (!empty){
+
+ if (!empty && (!map.getBounds() || !map.getBounds().equals(bounds))){
+ if (maxZoom !== null){
+ // fitBouds Callback event => detect zoom level and check maxZoom
+ google.maps.event.addListenerOnce(
+ map,
+ 'bounds_changed',
+ function() {
+ if (this.getZoom() > maxZoom){
+ this.setZoom(maxZoom);
+ }
+ }
+ );
+ }
map.fitBounds(bounds);
}
if (!internal){
@@ -2096,6 +2150,37 @@
$.fn.gmap3 = function(){
var i, args, list = [], empty = true, results = [];
+
+ if ($.isEmptyObject(_default)) {
+ _default = {
+ verbose: false,
+ queryLimit: {
+ attempt: 5,
+ delay: 250,
+ random: 250
+ },
+ init: {
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
+ center: [46.578498, 2.457275],
+ zoom: 2
+ },
+ classes: {
+ Map: google.maps.Map,
+ Marker: google.maps.Marker,
+ InfoWindow: google.maps.InfoWindow,
+ Circle: google.maps.Circle,
+ Rectangle: google.maps.Rectangle,
+ OverlayView: google.maps.OverlayView,
+ StreetViewPanorama: google.maps.StreetViewPanorama,
+ KmlLayer: google.maps.KmlLayer,
+ TrafficLayer: google.maps.TrafficLayer,
+ BicyclingLayer: google.maps.BicyclingLayer,
+ GroundOverlay: google.maps.GroundOverlay,
+ StyledMapType: google.maps.StyledMapType
+ }
+ };
+ }
+
// store all arguments in a todo list
for(i=0; i<arguments.length; i++){
args = arguments[i] || {};
View
33 jquery-gmap/assets/gmap3.min.js
@@ -1,39 +1,14 @@
/*
* GMAP3 Plugin for JQuery
- * Version : 4.0
- * Date : 2011-08-23
+ * Version : 4.1
+ * Date : 2011-11-18
* Licence : GPL v3 : http://www.gnu.org/licenses/gpl.html
* Author : DEMONTE Jean-Baptiste
* Contact : jbdemonte@gmail.com
* Web site : http://gmap3.net
*
* Copyright (c) 2010-2011 Jean-Baptiste DEMONTE
* All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * - Neither the name of the author nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
*/
-
- (function(c){function q(){var D=[];this.empty=function(){for(var E=0;E<D.length;E++){if(D[E]){return false}}return true};this.add=function(E){D.push(E)};this.addNext=function(F){var H=[],G,E=0;for(G=0;G<D.length;G++){if(!D[G]){continue}if(E==1){H.push(F)}H.push(D[G]);E++}if(E<2){H.push(F)}D=H};this.get=function(){for(var E=0;E<D.length;E++){if(D[E]){return D[E]}}return false};this.ack=function(){for(var E=0;E<D.length;E++){if(D[E]){delete D[E];break}}if(this.empty()){D=[]}}}function o(){var D={};this.add=function(F,G,E){F=F.toLowerCase();if(!D[F]){D[F]=[]}D[F].push({obj:G,tag:s(E,"tag")});return F+"-"+(D[F].length-1)};this.get=function(G,I,F){var H,E,J;G=G.toLowerCase();if(!D[G]||!D[G].length){return null}E=I?D[G].length:-1;J=I?-1:1;for(H=0;H<D[G].length;H++){E+=J;if(D[G][E]){if(F!==undefined){if((D[G][E].tag===undefined)||(c.inArray(D[G][E].tag,F)<0)){continue}}return D[G][E].obj}}return null};this.all=function(G,F){var H,E=[];G=G.toLowerCase();if(!D[G]||!D[G].length){return E}for(H=0;H<D[G].length;H++){if(!D[G][H]){continue}if((F!==undefined)&&((D[G][H].tag===undefined)||(c.inArray(D[G][H].tag,F)<0))){continue}E.push(D[G][H].obj)}return E};this.names=function(){var F,E=[];for(F in D){E.push(F)}return E};this.refToObj=function(E){E=E.split("-");if((E.length==2)&&D[E[0]]&&D[E[0]][E[1]]){return D[E[0]][E[1]].obj}return null};this.rm=function(H,F,G){var E,J,I;H=H.toLowerCase();if(!D[H]){return false}if(F!==undefined){if(G){for(E=D[H].length-1;E>=0;E--){if((D[H][E]!==undefined)&&(D[H][E].tag!==undefined)&&(c.inArray(D[H][E].tag,F)>=0)){break}}}else{for(E=0;E<D[H].length;E++){if((D[H][E]!==undefined)&&(D[H][E].tag!==undefined)&&(c.inArray(D[H][E].tag,F)>=0)){break}}}}else{E=G?D[H].length-1:0}if(!(E in D[H])){return false}if(typeof(D[H][E].obj.setMap)==="function"){D[H][E].obj.setMap(null)}if(typeof(D[H][E].obj.remove)==="function"){D[H][E].obj.remove()}if(typeof(D[H][E].obj.free)==="function"){D[H][E].obj.free()}delete D[H][E].obj;if(F!==undefined){I=[];for(J=0;J<D[H].length;J++){if(J!==E){I.push(D[H][J])}}D[H]=I}else{if(G){D[H].pop()}else{D[H].shift()}}return true};this.clear=function(J,I,K,E){var F,H,G;if(!J||!J.length){J=[];for(F in D){J.push(F)}}else{J=g(J)}for(H=0;H<J.length;H++){if(J[H]){G=J[H].toLowerCase();if(!D[G]){continue}if(I){this.rm(G,E,true)}else{if(K){this.rm(G,E,false)}else{while(this.rm(G,E,false)){}}}}}}}function z(){var H=[],E=[],F=[],D=[],G=false,I;this.events=function(){for(var J=0;J<arguments.length;J++){E.push(arguments[J])}};this.startRedraw=function(){if(!G){G=true;return true}return false};this.endRedraw=function(){G=false};this.redraw=function(){var K,J=[],L=this;for(K=0;K<arguments.length;K++){J.push(arguments[K])}if(this.startRedraw){I.apply(L,J);this.endRedraw()}else{setTimeout(function(){L.redraw.apply(L,J)},50)}};this.setRedraw=function(J){I=J};this.store=function(J,K,L){F.push({data:J,obj:K,shadow:L})};this.free=function(){for(var J=0;J<E.length;J++){google.maps.event.removeListener(E[J])}E=[];this.freeAll()};this.freeIndex=function(J){if(typeof(F[J].obj.setMap)==="function"){F[J].obj.setMap(null)}if(typeof(F[J].obj.remove)==="function"){F[J].obj.remove()}if(F[J].shadow){if(typeof(F[J].shadow.remove)==="function"){F[J].obj.remove()}if(typeof(F[J].shadow.setMap)==="function"){F[J].shadow.setMap(null)}delete F[J].shadow}delete F[J].obj;delete F[J].data;delete F[J]};this.freeAll=function(){var J;for(J=0;J<F.length;J++){if(F[J]){this.freeIndex(J)}}F=[]};this.freeDiff=function(M){var L,K,N={},J=[];for(L=0;L<M.length;L++){J.push(M[L].idx.join("-"))}for(L=0;L<F.length;L++){if(!F[L]){continue}K=c.inArray(F[L].data.idx.join("-"),J);if(K>=0){N[K]=true}else{this.freeIndex(L)}}return N};this.add=function(K,J){H.push({latLng:K,marker:J})};this.get=function(J){return H[J]};this.clusters=function(ag,L,K){var M=ag.getProjection(),X=M.fromLatLngToPoint(new google.maps.LatLng(ag.getBounds().getNorthEast().lat(),ag.getBounds().getSouthWest().lng())),ac,aa,J,W,U,T,Y,R,S=ag.getZoom(),O={},af={},ab={},Q=[],ad,ae,N,ah,V,Z,P=ag.getBounds();Z=0;V={};for(ac=0;ac<H.length;ac++){if(!P.contains(H[ac].latLng)){continue}W=M.fromLatLngToPoint(H[ac].latLng);O[ac]=[Math.floor((W.x-X.x)*Math.pow(2,S)),Math.floor((W.y-X.y)*Math.pow(2,S))];V[ac]=true;Z++}if(!K){for(Y=0;Y<D.length;Y++){if(Y in V){Z--}else{break}}if(!Z){return false}}D=V;V=[];for(ac in O){U=O[ac][0];T=O[ac][1];if(!(U in af)){af[U]={}}if(!(T in af[U])){af[U][T]=ac;ab[ac]={};V.push(ac)}ab[af[U][T]][ac]=true}L=Math.pow(L,2);delete (af);Y=0;while(1){while((Y<V.length)&&!(V[Y] in ab)){Y++}if(Y==V.length){break}ac=V[Y];N=O[ac][0];ah=O[ac][1];af=null;do{ad={lat:0,lng:0,idx:[]};for(R=Y;R<V.length;R++){if(!(V[R] in ab)){continue}aa=V[R];if(Math.pow(N-O[aa][0],2)+Math.pow(ah-O[aa][1],2)<=L){for(J in ab[aa]){ad.lat+=H[J].latLng.lat();ad.lng+=H[J].latLng.lng();ad.idx.push(J)}}}ad.lat/=ad.idx.length;ad.lng/=ad.idx.length;if(!af){ae=ad.idx.length>1;af=ad}else{ae=ad.idx.length>af.idx.length;if(ae){af=ad}}if(ae){W=M.fromLatLngToPoint(new google.maps.LatLng(af.lat,af.lng));N=Math.floor((W.x-X.x)*Math.pow(2,S));ah=Math.floor((W.y-X.y)*Math.pow(2,S))}}while(ae);for(R=0;R<af.idx.length;R++){if(af.idx[R] in ab){delete (ab[af.idx[R]])}}Q.push(af)}return Q};this.getBounds=function(){var J,K=new google.maps.LatLngBounds();for(J=0;J<H.length;J++){K.extend(H[J].latLng)}return K}}var e={verbose:false,queryLimit:{attempt:5,delay:250,random:250},init:{mapTypeId:google.maps.MapTypeId.ROADMAP,center:[46.578498,2.457275],zoom:2},classes:{Map:google.maps.Map,Marker:google.maps.Marker,InfoWindow:google.maps.InfoWindow,Circle:google.maps.Circle,Rectangle:google.maps.Rectangle,OverlayView:google.maps.OverlayView,StreetViewPanorama:google.maps.StreetViewPanorama,KmlLayer:google.maps.KmlLayer,TrafficLayer:google.maps.TrafficLayer,BicyclingLayer:google.maps.BicyclingLayer,GroundOverlay:google.maps.GroundOverlay,StyledMapType:google.maps.StyledMapType}},v=["events","onces","options","apply","callback","data","tag"],i=["init","geolatlng","getlatlng","getroute","getelevation","getdistance","addstyledmap","setdefault","destroy"],p=["get"],m=directionsService=elevationService=maxZoomService=distanceMatrixService=null;function B(E){for(var D in E){if(typeof(e[D])==="object"){e[D]=c.extend({},e[D],E[D])}else{e[D]=E[D]}}}function u(E){if(!E){return true}for(var D=0;D<i.length;D++){if(i[D]===E){return false}}return true}function n(D){var F=s(D,"action");for(var E=0;E<p.length;E++){if(p[E]===F){return true}}return false}function t(E,F){if(F.toLowerCase){F=F.toLowerCase();for(var D in E){if(D.toLowerCase&&(D.toLowerCase()==F)){return D}}}return false}function s(E,F,G){var D=t(E,F);return D?E[D]:G}function C(E,F){var G,D;if(!E||!F){return false}F=g(F);for(G in E){if(G.toLowerCase){G=G.toLowerCase();for(D in F){if(G==F[D]){return true}}}}return false}function h(F,E,D){if(C(F,v)||C(F,E)){var H,G;for(H=0;H<v.length;H++){G=t(F,v[H]);D[v[H]]=G?F[G]:{}}if(E&&E.length){for(H=0;H<E.length;H++){if(G=t(F,E[H])){D[E[H]]=F[G]}}}return D}else{D.options={};for(G in F){if(G!=="action"){D.options[G]=F[G]}}return D}}function A(H,F,E,G){var K=t(F,H),I,D={},J=["map"];D.callback=s(F,"callback");E=g(E);G=g(G);if(K){return h(F[K],E,D)}if(G&&G.length){for(I=0;I<G.length;I++){J.push(G[I])}}if(!C(F,J)){D=h(F,E,D)}for(I=0;I<v.length;I++){if(v[I] in D){continue}D[v[I]]={}}return D}function l(){if(!m){m=new google.maps.Geocoder()}return m}function a(){if(!directionsService){directionsService=new google.maps.DirectionsService()}return directionsService}function r(){if(!elevationService){elevationService=new google.maps.ElevationService()}return elevationService}function x(){if(!maxZoomService){maxZoomService=new google.maps.MaxZoomService()}return maxZoomService}function b(){if(!distanceMatrixService){distanceMatrixService=new google.maps.DistanceMatrixService()}return distanceMatrixService}function d(D){return(typeof(D)==="number"||typeof(D)==="string")&&D!==""&&!isNaN(D)}function g(F){var E,D=[];if(F!==undefined){if(typeof(F)==="object"){if(typeof(F.length)==="number"){D=F}else{for(E in F){D.push(F[E])}}}else{D.push(F)}}return D}function f(E,G,D){var F=G?E:null;if(!E||(typeof(E)==="string")){return F}if(E.latLng){return f(E.latLng)}if(typeof(E.lat)==="function"){return E}else{if(d(E.lat)){return new google.maps.LatLng(E.lat,E.lng)}else{if(!D&&E.length){if(!d(E[0])||!d(E[1])){return F}return new google.maps.LatLng(E[0],E[1])}}}return F}function j(E,F,I){var H,D,G;if(!E){return null}G=I?E:null;if(typeof(E.getCenter)==="function"){return E}if(E.length){if(E.length==2){H=f(E[0]);D=f(E[1])}else{if(E.length==4){H=f([E[0],E[1]]);D=f([E[2],E[3]])}}}else{if(("ne" in E)&&("sw" in E)){H=f(E.ne);D=f(E.sw)}else{if(("n" in E)&&("e" in E)&&("s" in E)&&("w" in E)){H=f([E.n,E.e]);D=f([E.s,E.w])}}}if(H&&D){return new google.maps.LatLngBounds(D,H)}return G}function w(I){var D=new q(),F=new o(),H=null,G={},E=false;this._plan=function(K){for(var J=0;J<K.length;J++){D.add(K[J])}this._run()};this._planNext=function(J){D.addNext(J)};this._direct=function(J){var K=s(J,"action");return this[K](c.extend({},K in e?e[K]:{},J.args?J.args:J))};this._end=function(){E=false;D.ack();this._run()},this._run=function(){if(E){return}var J=D.get();if(!J){return}E=true;this._proceed(J)};this._proceed=function(J){J=J||{};var O=s(J,"action")||"init",N=O.toLowerCase(),M=true,P=s(J,"target"),L=s(J,"args"),K;if(!H&&u(N)){this.init(c.extend({},e.init,J.args&&J.args.map?J.args.map:J.map?J.map:{}),true)}if(!P&&!L&&(N in this)&&(typeof(this[N])==="function")){this[N](c.extend({},N in e?e[N]:{},J.args?J.args:J))}else{if(P&&(typeof(P)==="object")){if(M=(typeof(P[O])==="function")){K=P[O].apply(P,J.args?J.args:[])}}else{if(H){if(M=(typeof(H[O])==="function")){K=H[O].apply(H,J.args?J.args:[])}}}if(!M&&e.verbose){alert("unknown action : "+O)}this._callback(K,J);this._end()}};this._resolveLatLng=function(J,P,M,L){var K=s(J,"address"),O,N=this;if(K){if(!L){L=0}if(typeof(K)==="object"){O=K}else{O={address:K}}l().geocode(O,function(R,Q){if(Q===google.maps.GeocoderStatus.OK){N[P](J,M?R:R[0].geometry.location)}else{if((Q===google.maps.GeocoderStatus.OVER_QUERY_LIMIT)&&(L<e.queryLimit.attempt)){setTimeout(function(){N._resolveLatLng(J,P,M,L+1)},e.queryLimit.delay+Math.floor(Math.random()*e.queryLimit.random))}else{if(e.verbose){alert("Geocode error : "+Q)}N[P](J,false)}}})}else{N[P](J,f(J,false,true))}},this._call=function(){var K,L=arguments[0],J=[];if(!arguments.length||!H||(typeof(H[L])!=="function")){return}for(K=1;K<arguments.length;K++){J.push(arguments[K])}return H[L].apply(H,J)};this._subcall=function(J,L){var K={};if(!J.map){return}if(!L){L=s(J.map,"latlng")}if(!H){if(L){K={center:L}}this.init(c.extend({},J.map,K),true)}else{if(J.map.center&&L){this._call("setCenter",L)}if(J.map.zoom!==undefined){this._call("setZoom",J.map.zoom)}if(J.map.mapTypeId!==undefined){this._call("setMapTypeId",J.map.mapTypeId)}}};this._attachEvent=function(K,J,N,M,L){google.maps.event["addListener"+(L?"Once":"")](K,J,function(O){N.apply(I,[K,O,M])})};this._attachEvents=function(L,J){var K;if(!J){return}if(J.events){for(K in J.events){if(typeof(J.events[K])==="function"){this._attachEvent(L,K,J.events[K],J.data,false)}}}if(J.onces){for(K in J.onces){if(typeof(J.onces[K])==="function"){this._attachEvent(L,K,J.onces[K],J.data,true)}}}};this._callback=function(K,J){if(typeof(J.callback)==="function"){J.callback.apply(I,[K])}else{if(typeof(J.callback)==="object"){for(var L=0;L<J.callback.length;L++){if(typeof(J.callback[L])==="function"){J.callback[k].apply(I,[K])}}}}};this._manageEnd=function(K,J,L){var N,M;if(K&&(typeof(K)==="object")){this._attachEvents(K,J);if(J.apply&&J.apply.length){for(N=0;N<J.apply.length;N++){M=J.apply[N];if(!M.action||(typeof(K[M.action])!=="function")){continue}if(M.args){K[M.action].apply(K,M.args)}else{K[M.action]()}}}}if(!L){this._callback(K,J);this._end()}};this.destroy=function(J){var K;F.clear();I.empty();for(K in G){delete G[K]}G={};if(H){delete H}this._callback(I,null,J);this._end()};this.init=function(J,K){var M,L;if(H){return this._end()}M=A("map",J);if((typeof(M.options.center)==="boolean")&&M.options.center){return false}opts=c.extend({},e.init,M.options);if(!opts.center){opts.center=[e.init.center.lat,e.init.center.lng]}opts.center=f(opts.center);H=new e.classes.Map(I.get(0),opts);for(L in G){H.mapTypes.set(L,G[L])}this._manageEnd(H,M,K);return true};this.getlatlng=function(J){this._resolveLatLng(J,"_getLatLng",true)},this._getLatLng=function(J,K){this._manageEnd(K,J)},this.getaddress=function(J){var L=f(J,false,true),K=s(J,"address"),M=L?{latLng:L}:(K?(typeof(K)==="string"?{address:K}:K):null),N=s(J,"callback");if(M&&typeof(N)==="function"){l().geocode(M,function(Q,O){var P=O===google.maps.GeocoderStatus.OK?Q:false;N.apply(I,[P,O])})}this._end()};this.getroute=function(J){var K=s(J,"callback");if((typeof(K)==="function")&&J.options){J.options.origin=f(J.options.origin,true);J.options.destination=f(J.options.destination,true);a().route(J.options,function(N,L){var M=L==google.maps.DirectionsStatus.OK?N:false;K.apply(I,[M,L])})}this._end()};this.getelevation=function(K){var P,N,O,L,M,J=[],Q=s(K,"callback"),N=s(K,"latlng");if(typeof(Q)==="function"){P=function(T,R){var S=R===google.maps.ElevationStatus.OK?T:false;Q.apply(I,[S,R])};if(N){J.push(f(N))}else{J=s(K,"locations")||[];if(J){J=g(J);for(M=0;M<J.length;M++){J[M]=f(J[M])}}}if(J.length){r().getElevationForLocations({locations:J},P)}else{O=s(K,"path");L=s(K,"samples");if(O&&L){for(M=0;M<O.length;M++){J.push(f(O[M]))}if(J.length){r().getElevationAlongPath({path:J,samples:L},P)}}}}this._end()};this.getdistance=function(J){var K,L=s(J,"callback");if((typeof(L)==="function")&&J.options&&J.options.origins&&J.options.destinations){J.options.origins=g(J.options.origins);for(K=0;K<J.options.origins.length;K++){J.options.origins[K]=f(J.options.origins[K],true)}J.options.destinations=g(J.options.destinations);for(K=0;K<J.options.destinations.length;K++){J.options.destinations[K]=f(J.options.destinations[K],true)}b().getDistanceMatrix(J.options,function(O,M){var N=M==google.maps.DistanceMatrixStatus.OK?O:false;L.apply(I,[N,M])})}};this.addmarker=function(J){this._resolveLatLng(J,"_addMarker")};this._addMarker=function(K,N,L){var J,M,P,O=A("marker",K,"to");if(!L){if(!N){this._manageEnd(false,O);return}this._subcall(K,N)}else{if(!N){return}}if(O.to){P=F.refToObj(O.to);J=P&&(typeof(P.add)==="function");if(J){P.add(N,K);if(typeof(P.redraw)==="function"){P.redraw()}}if(!L){this._manageEnd(J,O)}}else{O.options.position=N;O.options.map=H;J=new e.classes.Marker(O.options);if(C(K,"infowindow")){M=A("infowindow",K.infowindow,"open");if((M.open===undefined)||M.open){M.apply=g(M.apply);M.apply.unshift({action:"open",args:[H,J]})}M.action="addinfowindow";this._planNext(M)}if(!L){F.add("marker",J,O);this._manageEnd(J,O)}}return J};this.addmarkers=function(J){if(s(J,"clusters")){this._addclusteredmarkers(J)}else{this._addmarkers(J)}};this._addmarkers=function(L){var S,J,N,K,P,R={},O,Q,M=s(L,"markers");this._subcall(L);if(typeof(M)!=="object"){return this._end()}J=A("marker",L,["to","markers"]);if(J.to){Q=F.refToObj(J.to);S=Q&&(typeof(Q.add)==="function");if(S){for(N=0;N<M.length;N++){if(K=f(M[N])){Q.add(K,M[N])}}if(typeof(Q.redraw)==="function"){Q.redraw()}}this._manageEnd(S,J)}else{c.extend(true,R,J.options);R.map=H;S=[];for(N=0;N<M.length;N++){if(K=f(M[N])){if(M[N].options){O={};c.extend(true,O,R,M[N].options);J.options=O}else{J.options=R}J.options.position=K;P=new e.classes.Marker(J.options);S.push(P);J.data=M[N].data;J.tag=M[N].tag;F.add("marker",P,J);this._manageEnd(P,J,true)}}J.options=R;this._callback(S,L);this._end()}};this._addclusteredmarkers=function(K){var N,M,J,Q,O=this,P=s(K,"radius"),L=s(K,"markers"),R=s(K,"clusters");if(!H.getBounds()){google.maps.event.addListenerOnce(H,"bounds_changed",function(){O._addclusteredmarkers(K)});return}if(typeof(P)==="number"){N=new z();for(M=0;M<L.length;M++){J=f(L[M]);N.add(J,L[M])}Q=this._initClusters(K,N,P,R)}this._callback(Q,K);this._end()};this._initClusters=function(K,L,J,N){var M=this;L.setRedraw(function(P){var Q,O=L.clusters(H,J,P);if(O){Q=L.freeDiff(O);M._displayClusters(K,L,O,Q,N)}});L.events(google.maps.event.addListener(H,"zoom_changed",function(){L.redraw(true)}),google.maps.event.addListener(H,"bounds_changed",function(){L.redraw()}));L.redraw();return F.add("cluster",L,K)};this._displayClusters=function(N,Y,M,X,O){var W,Z,R,V,T,S,L,aa,J,ac,Q,ab,K,P=C(N,"cluster")?A("",s(N,"cluster")):{},U=C(N,"marker")?A("",s(N,"marker")):{};for(Z=0;Z<M.length;Z++){if(Z in X){continue}aa=M[Z];T=false;if(aa.idx.length>1){V=0;for(W in O){if((W>V)&&(W<=aa.idx.length)){V=W}}if(O[V]){Q=s(O[V],"width");ab=s(O[V],"height");K={};c.extend(true,K,P,{options:{pane:"overlayLayer",content:O[V].content.replace("CLUSTER_COUNT",aa.idx.length),offset:{x:-Q/2,y:-ab/2}}});S=this._addOverlay(K,f(aa),true);K.options.pane="floatShadow";K.options.content=c("<div></div>");K.options.content.width(Q);K.options.content.height(ab);L=this._addOverlay(K,f(aa),true);P.data={latLng:f(aa),markers:[]};for(R=0;R<aa.idx.length;R++){P.data.markers.push(Y.get(aa.idx[R]).marker)}this._attachEvents(L,P);Y.store(aa,S,L);T=true}}if(!T){J={};c.extend(true,J,U.options);for(R=0;R<aa.idx.length;R++){V=Y.get(aa.idx[R]);U.latLng=V.latLng;U.data=V.marker.data;U.tag=V.marker.tag;if(V.marker.options){ac={};c.extend(true,ac,J,V.marker.options);U.options=ac}else{U.options=J}S=this._addMarker(U,U.latLng,true);this._attachEvents(S,U);Y.store(aa,S)}U.options=J}}};this.addinfowindow=function(J){this._resolveLatLng(J,"_addInfoWindow")};this._addInfoWindow=function(J,L){var N,M,K=[];this._subcall(J,L);N=A("infowindow",J,["open","anchor"]);if(L){N.options.position=L}M=new e.classes.InfoWindow(N.options);if((N.open===undefined)||N.open){N.apply=g(N.apply);K.push(H);if(N.anchor){K.push(N.anchor)}N.apply.unshift({action:"open",args:K})}F.add("infowindow",M,N);this._manageEnd(M,N)};this.addpolyline=function(J){this._addPoly(J,"Polyline","path")};this.addpolygon=function(J){this._addPoly(J,"Polygon","paths")};this._addPoly=function(J,M,O){var K,N,L,P=A(M.toLowerCase(),J,O);if(P[O]){P.options[O]=[];for(K=0;K<P[O].length;K++){if(L=f(P[O][K])){P.options[O].push(L)}}}N=new google.maps[M](P.options);N.setMap(H);F.add(M.toLowerCase(),N,P);this._manageEnd(N,P)};this.addcircle=function(J){this._resolveLatLng(J,"_addCircle")};this._addCircle=function(J,K){var M,L=A("circle",J);if(!K){K=f(L.options.center)}if(!K){return this._manageEnd(false,L)}this._subcall(J,K);L.options.center=K;L.options.map=H;M=new e.classes.Circle(L.options);F.add("circle",M,L);this._manageEnd(M,L)};this.addrectangle=function(J){this._resolveLatLng(J,"_addRectangle")};this._addRectangle=function(J,L){var K,M=A("rectangle",J);M.options.bounds=j(M.options.bounds,true);if(!M.options.bounds){return this._manageEnd(false,M)}this._subcall(J,M.options.bounds.getCenter());M.options.map=H;K=new e.classes.Rectangle(M.options);F.add("rectangle",K,M);this._manageEnd(K,M)};this.addoverlay=function(J){this._resolveLatLng(J,"_addOverlay")};this._addOverlay=function(N,L,O){var M,K=A("overlay",N),J=c.extend({pane:"floatPane",content:"",offset:{x:0,y:0}},K.options),R=c("<div></div>"),Q=[];R.css("border","none").css("borderWidth","0px").css("position","absolute");R.append(J.content);function P(){e.classes.OverlayView.call(this);this.setMap(H)}P.prototype=new e.classes.OverlayView();P.prototype.onAdd=function(){var S=this.getPanes();if(J.pane in S){c(S[J.pane]).append(R)}};P.prototype.draw=function(){var S=this.getProjection(),U=S.fromLatLngToDivPixel(L),T=this;R.css("left",(U.x+J.offset.x)+"px").css("top",(U.y+J.offset.y)+"px");c.each(("dblclick click mouseover mousemove mouseout mouseup mousedown").split(" "),function(W,V){Q.push(google.maps.event.addDomListener(R[0],V,function(X){google.maps.event.trigger(T,V)}))});Q.push(google.maps.event.addDomListener(R[0],"contextmenu",function(V){google.maps.event.trigger(T,"rightclick")}))};P.prototype.onRemove=function(){for(var S=0;S<Q.length;S++){google.maps.event.removeListener(Q[S])}R.remove()};P.prototype.hide=function(){R.hide()};P.prototype.show=function(){R.show()};P.prototype.toggle=function(){if(R){if(R.is(":visible")){this.show()}else{this.hide()}}};P.prototype.toggleDOM=function(){if(this.getMap()){this.setMap(null)}else{this.setMap(H)}};P.prototype.getDOMElement=function(){return R[0]};M=new P();if(!O){F.add("overlay",M,K);this._manageEnd(M,K)}return M};this.addfixpanel=function(K){var N=A("fixpanel",K),J=y=0,M,L;if(N.options.content){M=c(N.options.content);if(N.options.left!==undefined){J=N.options.left}else{if(N.options.right!==undefined){J=I.width()-M.width()-N.options.right}else{if(N.options.center){J=(I.width()-M.width())/2}}}if(N.options.top!==undefined){y=N.options.top}else{if(N.options.bottom!==undefined){y=I.height()-M.height()-N.options.bottom}else{if(N.options.middle){y=(I.height()-M.height())/2}}}L=c("<div></div>").css("position","absolute").css("top",y+"px").css("left",J+"px").css("z-index","1000").append(M);I.first().prepend(L);this._attachEvents(H,N);F.add("fixpanel",L,N);this._callback(L,N)}this._end()};this.adddirectionsrenderer=function(J,K){var L,M=A("directionrenderer",J,"panelId");F.rm("directionrenderer");M.options.map=H;L=new google.maps.DirectionsRenderer(M.options);if(M.panelId){L.setPanel(document.getElementById(M.panelId))}F.add("directionrenderer",L,M);this._manageEnd(L,M,K);return L};this.setdirectionspanel=function(J){var K=F.get("directionrenderer"),L=A("directionpanel",J,"id");if(K&&L.id){K.setPanel(document.getElementById(L.id))}this._manageEnd(K,L)};this.setdirections=function(J){var K=F.get("directionrenderer"),L=A("directions",J);if(J){L.options.directions=J.directions?J.directions:(J.options&&J.options.directions?J.options.directions:null)}if(L.options.directions){if(!K){K=this.adddirectionsrenderer(L,true)}else{K.setDirections(L.options.directions)}}this._manageEnd(K,L)};this.setstreetview=function(J){var K,L=A("streetview",J,"id");if(L.options.position){L.options.position=f(L.options.position)}K=new e.classes.StreetViewPanorama(document.getElementById(L.id),L.options);if(K){H.setStreetView(K)}this._manageEnd(K,L)};this.addkmllayer=function(K){var J,L=A("kmllayer",K,"url");L.options.map=H;if(typeof(L.url)==="string"){J=new e.classes.KmlLayer(L.url,L.options)}F.add("kmllayer",J,L);this._manageEnd(J,L)};this.addtrafficlayer=function(J){var L=A("trafficlayer",J),K=F.get("trafficlayer");if(!K){K=new e.classes.TrafficLayer();K.setMap(H);F.add("trafficlayer",K,L)}this._manageEnd(K,L)};this.addbicyclinglayer=function(J){var K=A("bicyclinglayer",J),L=F.get("bicyclinglayer");if(!L){L=new e.classes.BicyclingLayer();L.setMap(H);F.add("bicyclinglayer",L,K)}this._manageEnd(L,K)};this.addgroundoverlay=function(J){var K,L=A("groundoverlay",J,["bounds","url"]);L.bounds=j(L.bounds);if(L.bounds&&(typeof(L.url)==="string")){K=new e.classes.GroundOverlay(L.url,L.bounds);K.setMap(H);F.add("groundoverlay",K,L)}this._manageEnd(K,L)};this.geolatlng=function(J){var K=s(J,"callback");if(typeof(K)==="function"){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(L){var M=new google.maps.LatLng(L.coords.latitude,L.coords.longitude);K.apply(I,[M])},function(){var L=false;K.apply(I,[L])})}else{if(google.gears){google.gears.factory.create("beta.geolocation").getCurrentPosition(function(L){var M=new google.maps.LatLng(L.latitude,L.longitude);K.apply(I,[M])},function(){out=false;K.apply(I,[out])})}else{K.apply(I,[false])}}}this._end()};this.addstyledmap=function(J,K){var L=A("styledmap",J,["id","style"]);if(L.style&&L.id&&!G[L.id]){G[L.id]=new e.classes.StyledMapType(L.style,L.options);if(H){H.mapTypes.set(L.id,G[L.id])}}this._manageEnd(G[L.id],L,K)};this.setstyledmap=function(J){var K=A("styledmap",J,["id","style"]);if(K.id){this.addstyledmap(K,true);if(G[K.id]){H.setMapTypeId(K.id);this._callback(G[K.id],J)}}this._manageEnd(G[K.id],K)};this.clear=function(K){var M=g(s(K,"list")||s(K,"name")),L=s(K,"last",false),N=s(K,"first",false),J=s(K,"tag");if(J!==undefined){J=g(J)}F.clear(M,L,N,J);this._end()};this.get=function(K){var L=s(K,"name")||"map",N=s(K,"first"),M=s(K,"all"),J=s(K,"tag");L=L.toLowerCase();if(L==="map"){return H}if(J!==undefined){J=g(J)}if(N){return F.get(L,false,J)}else{if(M){return F.all(L,J)}else{return F.get(L,true,J)}}};this.getmaxzoom=function(J){this._resolveLatLng(J,"_getMaxZoom")};this._getMaxZoom=function(J,K){var L=s(J,"callback");if(L&&typeof(L)==="function"){x().getMaxZoomAtLatLng(K,function(M){var N=M.status===google.maps.MaxZoomStatus.OK?M.zoom:false;L.apply(I,[N,M.status])})}this._end()};this.setdefault=function(J){B(J);this._end()};this.autofit=function(K,O){var R,Q,M,N,L,P=true,J=new google.maps.LatLngBounds();R=F.names();for(N=0;N<R.length;N++){Q=F.all(R[N]);for(L=0;L<Q.length;L++){M=Q[L];if(M.getPosition){J.extend(M.getPosition());P=false}else{if(M.getBounds){J.extend(M.getBounds().getNorthEast());J.extend(M.getBounds().getSouthWest());P=false}else{if(M.getPaths){M.getPaths().forEach(function(S){S.forEach(function(T){J.extend(T);P=false})})}else{if(M.getPath){M.getPath().forEach(function(S){J.extend(S);P=false})}else{if(M.getCenter){J.extend(M.getCenter());P=false}}}}}}}if(!P){H.fitBounds(J)}if(!O){this._manageEnd(P?false:J,K,O)}}}c.fn.gmap3=function(){var F,D,H=[],G=true,E=[];for(F=0;F<arguments.length;F++){D=arguments[F]||{};if(typeof(D)==="string"){D={action:D}}H.push(D)}if(!H.length){H.push({})}c.each(this,function(){var I=c(this),J=I.data("gmap3");G=false;if(!J){J=new w(I);I.data("gmap3",J)}if((H.length==1)&&(n(H[0]))){E.push(J._direct(H[0]))}else{J._plan(H)}});if(E.length){if(E.length===1){return E[0]}else{return E}}if(G&&(arguments.length==2)&&(typeof(arguments[0])==="string")&&(arguments[0].toLowerCase()==="setdefault")){B(arguments[1])}return this}}(jQuery));
+
+(function($){function Stack(){var st=[];this.empty=function(){for(var i=0;i<st.length;i++){if(st[i]){return false}}return true}this.add=function(v){st.push(v)}this.addNext=function(v){var t=[],i,k=0;for(i=0;i<st.length;i++){if(!st[i]){continue}if(k==1){t.push(v)}t.push(st[i]);k++}if(k<2){t.push(v)}st=t}this.get=function(){for(var i=0;i<st.length;i++){if(st[i]){return st[i]}}return false}this.ack=function(){for(var i=0;i<st.length;i++){if(st[i]){delete st[i];break}}if(this.empty()){st=[]}}}function Store(){var store={};this.add=function(name,obj,todo){name=name.toLowerCase();if(!store[name]){store[name]=[]}store[name].push({obj:obj,tag:ival(todo,'tag')});return name+'-'+(store[name].length-1)}this.get=function(name,last,tag){var i,idx,add;name=name.toLowerCase();if(!store[name]||!store[name].length){return null}idx=last?store[name].length:-1;add=last?-1:1;for(i=0;i<store[name].length;i++){idx+=add;if(store[name][idx]){if(tag!==undefined){if((store[name][idx].tag===undefined)||($.inArray(store[name][idx].tag,tag)<0)){continue}}return store[name][idx].obj}}return null}this.all=function(name,tag){var i,result=[];name=name.toLowerCase();if(!store[name]||!store[name].length){return result}for(i=0;i<store[name].length;i++){if(!store[name][i]){continue}if((tag!==undefined)&&((store[name][i].tag===undefined)||($.inArray(store[name][i].tag,tag)<0))){continue}result.push(store[name][i].obj)}return result}this.names=function(){var name,result=[];for(name in store){result.push(name)}return result}this.refToObj=function(ref){ref=ref.split('-');if((ref.length==2)&&store[ref[0]]&&store[ref[0]][ref[1]]){return store[ref[0]][ref[1]].obj}return null}this.rm=function(name,tag,pop){var idx,i,tmp;name=name.toLowerCase();if(!store[name]){return false}if(tag!==undefined){if(pop){for(idx=store[name].length-1;idx>=0;idx--){if((store[name][idx]!==undefined)&&(store[name][idx].tag!==undefined)&&($.inArray(store[name][idx].tag,tag)>=0)){break}}}else{for(idx=0;idx<store[name].length;idx++){if((store[name][idx]!==undefined)&&(store[name][idx].tag!==undefined)&&($.inArray(store[name][idx].tag,tag)>=0)){break}}}}else{idx=pop?store[name].length-1:0}if(!(idx in store[name])){return false}if(typeof(store[name][idx].obj.setMap)==='function'){store[name][idx].obj.setMap(null)}if(typeof(store[name][idx].obj.remove)==='function'){store[name][idx].obj.remove()}if(typeof(store[name][idx].obj.free)==='function'){store[name][idx].obj.free()}delete store[name][idx].obj;if(tag!==undefined){tmp=[];for(i=0;i<store[name].length;i++){if(i!==idx){tmp.push(store[name][i])}}store[name]=tmp}else{if(pop){store[name].pop()}else{store[name].shift()}}return true}this.clear=function(list,last,first,tag){var k,i,name;if(!list||!list.length){list=[];for(k in store){list.push(k)}}else{list=array(list)}for(i=0;i<list.length;i++){if(list[i]){name=list[i].toLowerCase();if(!store[name]){continue}if(last){this.rm(name,tag,true)}else if(first){this.rm(name,tag,false)}else{while(this.rm(name,tag,false))}}}}}function Clusterer(){var markers=[],events=[],stored=[],latest=[],redrawing=false,redraw;this.events=function(){for(var i=0;i<arguments.length;i++){events.push(arguments[i])}}this.startRedraw=function(){if(!redrawing){redrawing=true;return true}return false}this.endRedraw=function(){redrawing=false}this.redraw=function(){var i,args=[],that=this;for(i=0;i<arguments.length;i++){args.push(arguments[i])}if(this.startRedraw){redraw.apply(that,args);this.endRedraw()}else{setTimeout(function(){that.redraw.apply(that,args)},50)}};this.setRedraw=function(fnc){redraw=fnc}this.store=function(data,obj,shadow){stored.push({data:data,obj:obj,shadow:shadow})}this.free=function(){for(var i=0;i<events.length;i++){google.maps.event.removeListener(events[i])}events=[];this.freeAll()}this.freeIndex=function(i){if(typeof(stored[i].obj.setMap)==='function'){stored[i].obj.setMap(null)}if(typeof(stored[i].obj.remove)==='function'){stored[i].obj.remove()}if(stored[i].shadow){if(typeof(stored[i].shadow.remove)==='function'){stored[i].obj.remove()}if(typeof(stored[i].shadow.setMap)==='function'){stored[i].shadow.setMap(null)}delete stored[i].shadow}delete stored[i].obj;delete stored[i].data;delete stored[i]}this.freeAll=function(){var i;for(i=0;i<stored.length;i++){if(stored[i]){this.freeIndex(i)}}stored=[]}this.freeDiff=function(clusters){var i,j,same={},idx=[];for(i=0;i<clusters.length;i++){idx.push(clusters[i].idx.join('-'))}for(i=0;i<stored.length;i++){if(!stored[i]){continue}j=$.inArray(stored[i].data.idx.join('-'),idx);if(j>=0){same[j]=true}else{this.freeIndex(i)}}return same}this.add=function(latLng,marker){markers.push({latLng:latLng,marker:marker})}this.get=function(i){return markers[i]}this.clusters=function(map,radius,maxZoom,force){var proj=map.getProjection(),nwP=proj.fromLatLngToPoint(new google.maps.LatLng(map.getBounds().getNorthEast().lat(),map.getBounds().getSouthWest().lng())),i,j,j2,p,x,y,k,k2,z=map.getZoom(),pos={},saved={},unik={},clusters=[],cluster,chk,lat,lng,keys,cnt,bounds=map.getBounds(),noClusters=maxZoom&&(maxZoom<=map.getZoom()),chkContain=map.getZoom()>2;cnt=0;keys={};for(i=0;i<markers.length;i++){if(chkContain&&!bounds.contains(markers[i].latLng)){continue}p=proj.fromLatLngToPoint(markers[i].latLng);pos[i]=[Math.floor((p.x-nwP.x)*Math.pow(2,z)),Math.floor((p.y-nwP.y)*Math.pow(2,z))];keys[i]=true;cnt++}if(!force&&!noClusters){for(k=0;k<latest.length;k++){if(k in keys){cnt--}else{break}}if(!cnt){return false}}latest=keys;keys=[];for(i in pos){x=pos[i][0];y=pos[i][1];if(!(x in saved)){saved[x]={}}if(!(y in saved[x])){saved[x][y]=i;unik[i]={};keys.push(i)}unik[saved[x][y]][i]=true}radius=Math.pow(radius,2);delete(saved);k=0;while(1){while((k<keys.length)&&!(keys[k]in unik)){k++}if(k==keys.length){break}i=keys[k];lat=pos[i][0];lng=pos[i][1];saved=null;if(noClusters){saved={lat:lat,lng:lng,idx:[i]}}else{do{cluster={lat:0,lng:0,idx:[]};for(k2=k;k2<keys.length;k2++){if(!(keys[k2]in unik)){continue}j=keys[k2];if(Math.pow(lat-pos[j][0],2)+Math.pow(lng-pos[j][1],2)<=radius){for(j2 in unik[j]){cluster.lat+=markers[j2].latLng.lat();cluster.lng+=markers[j2].latLng.lng();cluster.idx.push(j2)}}}cluster.lat/=cluster.idx.length;cluster.lng/=cluster.idx.length;if(!saved){chk=cluster.idx.length>1;saved=cluster}else{chk=cluster.idx.length>saved.idx.length;if(chk){saved=cluster}}if(chk){p=proj.fromLatLngToPoint(new google.maps.LatLng(saved.lat,saved.lng));lat=Math.floor((p.x-nwP.x)*Math.pow(2,z));lng=Math.floor((p.y-nwP.y)*Math.pow(2,z))}}while(chk)}for(k2=0;k2<saved.idx.length;k2++){if(saved.idx[k2]in unik){delete(unik[saved.idx[k2]])}}clusters.push(saved)}return clusters}this.getBounds=function(){var i,bounds=new google.maps.LatLngBounds();for(i=0;i<markers.length;i++){bounds.extend(markers[i].latLng)}return bounds}}var _default={},_properties=['events','onces','options','apply','callback','data','tag'],_noInit=['init','geolatlng','getlatlng','getroute','getelevation','getdistance','addstyledmap','setdefault','destroy'],_directs=['get'],geocoder=directionsService=elevationService=maxZoomService=distanceMatrixService=null;function setDefault(values){for(var k in values){if(typeof(_default[k])==='object'){_default[k]=$.extend({},_default[k],values[k])}else{_default[k]=values[k]}}}function autoInit(iname){if(!iname){return true}for(var i=0;i<_noInit.length;i++){if(_noInit[i]===iname){return false}}return true}function isDirect(todo){var action=ival(todo,'action');for(var i=0;i<_directs.length;i++){if(_directs[i]===action){return true}}return false}function ikey(object,key){if(key.toLowerCase){key=key.toLowerCase();for(var k in object){if(k.toLowerCase&&(k.toLowerCase()==key)){return k}}}return false}function ival(object,key,def){var k=ikey(object,key);return k?object[k]:def}function hasKey(object,keys){var n,k;if(!object||!keys){return false}keys=array(keys);for(n in object){if(n.toLowerCase){n=n.toLowerCase();for(k in keys){if(n==keys[k]){return true}}}}return false}function extractObject(todo,include,result){if(hasKey(todo,_properties)||hasKey(todo,include)){var i,k;for(i=0;i<_properties.length;i++){k=ikey(todo,_properties[i]);result[_properties[i]]=k?todo[k]:{}}if(include&&include.length){for(i=0;i<include.length;i++){if(k=ikey(todo,include[i])){result[include[i]]=todo[k]}}}return result}else{result.options={};for(k in todo){if(k!=='action'){result.options[k]=todo[k]}}return result}}function getObject(name,todo,include,exclude){var iname=ikey(todo,name),i,result={},keys=['map'];result['callback']=ival(todo,'callback');include=array(include);exclude=array(exclude);if(iname){return extractObject(todo[iname],include,result)}if(exclude&&exclude.length){for(i=0;i<exclude.length;i++){keys.push(exclude[i])}}if(!hasKey(todo,keys)){result=extractObject(todo,include,result)}for(i=0;i<_properties.length;i++){if(_properties[i]in result){continue}result[_properties[i]]={}}return result}function getGeocoder(){if(!geocoder){geocoder=new google.maps.Geocoder()}return geocoder}function getDirectionsService(){if(!directionsService){directionsService=new google.maps.DirectionsService()}return directionsService}function getElevationService(){if(!elevationService){elevationService=new google.maps.ElevationService()}return elevationService}function getMaxZoomService(){if(!maxZoomService){maxZoomService=new google.maps.MaxZoomService()}return maxZoomService}function getDistanceMatrixService(){if(!distanceMatrixService){distanceMatrixService=new google.maps.DistanceMatrixService()}return distanceMatrixService}function numeric(mixed){return(typeof(mixed)==='number'||typeof(mixed)==='string')&&mixed!==''&&!isNaN(mixed)}function array(mixed){var k,a=[];if(mixed!==undefined){if(typeof(mixed)==='object'){if(typeof(mixed.length)==='number'){a=mixed}else{for(k in mixed){a.push(mixed[k])}}}else{a.push(mixed)}}return a}function toLatLng(mixed,emptyReturnMixed,noFlat){var empty=emptyReturnMixed?mixed:null;if(!mixed||(typeof(mixed)==='string')){return empty}if(mixed.latLng){return toLatLng(mixed.latLng)}if(typeof(mixed.lat)==='function'){return mixed}else if(numeric(mixed.lat)){return new google.maps.LatLng(mixed.lat,mixed.lng)}else if(!noFlat&&mixed.length){if(!numeric(mixed[0])||!numeric(mixed[1])){return empty}return new google.maps.LatLng(mixed[0],mixed[1])}return empty}function toLatLngBounds(mixed,flatAllowed,emptyReturnMixed){var ne,sw,empty;if(!mixed){return null}empty=emptyReturnMixed?mixed:null;if(typeof(mixed.getCenter)==='function'){return mixed}if(mixed.length){if(mixed.length==2){ne=toLatLng(mixed[0]);sw=toLatLng(mixed[1])}else if(mixed.length==4){ne=toLatLng([mixed[0],mixed[1]]);sw=toLatLng([mixed[2],mixed[3]])}}else{if(('ne'in mixed)&&('sw'in mixed)){ne=toLatLng(mixed.ne);sw=toLatLng(mixed.sw)}else if(('n'in mixed)&&('e'in mixed)&&('s'in mixed)&&('w'in mixed)){ne=toLatLng([mixed.n,mixed.e]);sw=toLatLng([mixed.s,mixed.w])}}if(ne&&sw){return new google.maps.LatLngBounds(sw,ne)}return empty}function Gmap3($this){var stack=new Stack(),store=new Store(),map=null,styles={},running=false;this._plan=function(list){for(var k=0;k<list.length;k++){stack.add(list[k])}this._run()}this._planNext=function(todo){stack.addNext(todo)}this._direct=function(todo){var action=ival(todo,'action');return this[action]($.extend({},action in _default?_default[action]:{},todo.args?todo.args:todo))}this._end=function(){running=false;stack.ack();this._run()},this._run=function(){if(running){return}var todo=stack.get();if(!todo){return}running=true;this._proceed(todo)}this._proceed=function(todo){todo=todo||{};var action=ival(todo,'action')||'init',iaction=action.toLowerCase(),ok=true,target=ival(todo,'target'),args=ival(todo,'args'),out;if(!map&&autoInit(iaction)){this.init($.extend({},_default.init,todo.args&&todo.args.map?todo.args.map:todo.map?todo.map:{}),true)}if(!target&&!args&&(iaction in this)&&(typeof(this[iaction])==='function')){this[iaction]($.extend({},iaction in _default?_default[iaction]:{},todo.args?todo.args:todo))}else{if(target&&(typeof(target)==='object')){if(ok=(typeof(target[action])==='function')){out=target[action].apply(target,todo.args?todo.args:[])}}else if(map){if(ok=(typeof(map[action])==='function')){out=map[action].apply(map,todo.args?todo.args:[])}}if(!ok&&_default.verbose){alert("unknown action : "+action)}this._callback(out,todo);this._end()}}this._resolveLatLng=function(todo,method,all,attempt){var address=ival(todo,'address'),params,that=this,fnc=typeof(method)==='function'?method:that[method];if(address){if(!attempt){attempt=0}if(typeof(address)==='object'){params=address}else{params={'address':address}}getGeocoder().geocode(params,function(results,status){if(status===google.maps.GeocoderStatus.OK){fnc.apply(that,[todo,all?results:results[0].geometry.location])}else if((status===google.maps.GeocoderStatus.OVER_QUERY_LIMIT)&&(attempt<_default.queryLimit.attempt)){setTimeout(function(){that._resolveLatLng(todo,method,all,attempt+1)},_default.queryLimit.delay+Math.floor(Math.random()*_default.queryLimit.random))}else{if(_default.verbose){alert('Geocode error : '+status)}fnc.apply(that,[todo,false])}})}else{fnc.apply(that,[todo,toLatLng(todo,false,true)])}}this._resolveAllLatLng=function(todo,property,method){var that=this,i=-1,solveNext=function(){do{i++}while((i<todo[property].length)&&!('address'in todo[property][i]));if(i<todo[property].length){(function(todo){that._resolveLatLng(todo,function(todo,latLng){todo.latLng=latLng;solveNext.apply(that,[])})})(todo[property][i])}else{that[method](todo)}};solveNext()}this._call=function(){var i,fname=arguments[0],args=[];if(!arguments.length||!map||(typeof(map[fname])!=='function')){return}for(i=1;i<arguments.length;i++){args.push(arguments[i])}return map[fname].apply(map,args)}this._subcall=function(todo,latLng){var opts={};if(!todo.map)return;if(!latLng){latLng=ival(todo.map,'latlng')}if(!map){if(latLng){opts={center:latLng}}this.init($.extend({},todo.map,opts),true)}else{if(todo.map.center&&latLng){this._call("setCenter",latLng)}if(todo.map.zoom!==undefined){this._call("setZoom",todo.map.zoom)}if(todo.map.mapTypeId!==undefined){this._call("setMapTypeId",todo.map.mapTypeId)}}}this._attachEvent=function(sender,name,fnc,data,once){google.maps.event['addListener'+(once?'Once':'')](sender,name,function(event){fnc.apply($this,[sender,event,data])})}this._attachEvents=function(sender,todo){var name;if(!todo){return}if(todo.events){for(name in todo.events){if(typeof(todo.events[name])==='function'){this._attachEvent(sender,name,todo.events[name],todo.data,false)}}}if(todo.onces){for(name in todo.onces){if(typeof(todo.onces[name])==='function'){this._attachEvent(sender,name,todo.onces[name],todo.data,true)}}}}this._callback=function(result,todo){if(typeof(todo.callback)==='function'){todo.callback.apply($this,[result])}else if(typeof(todo.callback)==='object'){for(var i=0;i<todo.callback.length;i++){if(typeof(todo.callback[i])==='function'){todo.callback[k].apply($this,[result])}}}}this._manageEnd=function(result,todo,internal){var i,apply;if(result&&(typeof(result)==='object')){this._attachEvents(result,todo);if(todo.apply&&todo.apply.length){for(i=0;i<todo.apply.length;i++){apply=todo.apply[i];if(!apply.action||(typeof(result[apply.action])!=='function')){continue}if(apply.args){result[apply.action].apply(result,apply.args)}else{result[apply.action]()}}}}if(!internal){this._callback(result,todo);this._end()}}this.destroy=function(todo){var k;store.clear();$this.empty();for(k in styles){delete styles[k]}styles={};if(map){delete map}this._callback(null,todo);this._end()}this.init=function(todo,internal){var o,k,opts;if(map){return this._end()}o=getObject('map',todo);if((typeof(o.options.center)==='boolean')&&o.options.center){return false}opts=$.extend({},_default.init,o.options);if(!opts.center){opts.center=[_default.init.center.lat,_default.init.center.lng]}opts.center=toLatLng(opts.center);map=new _default.classes.Map($this.get(0),opts);for(k in styles){map.mapTypes.set(k,styles[k])}this._manageEnd(map,o,internal);return true}this.getlatlng=function(todo){this._resolveLatLng(todo,'_getLatLng',true)},this._getLatLng=function(todo,results){this._manageEnd(results,todo)},this.getaddress=function(todo,attempt){var latLng=toLatLng(todo,false,true),address=ival(todo,'address'),params=latLng?{latLng:latLng}:(address?(typeof(address)==='string'?{address:address}:address):null),callback=ival(todo,'callback'),that=this;if(!attempt){attempt=0}if(params&&typeof(callback)==='function'){getGeocoder().geocode(params,function(results,status){if((status===google.maps.GeocoderStatus.OVER_QUERY_LIMIT)&&(attempt<_default.queryLimit.attempt)){setTimeout(function(){that.getaddress(todo,attempt+1)},_default.queryLimit.delay+Math.floor(Math.random()*_default.queryLimit.random))}else{var out=status===google.maps.GeocoderStatus.OK?results:false;callback.apply($this,[out,status]);if(!out&&_default.verbose){alert('Geocode error : '+status)}that._end()}})}else{this._end()}}this.getroute=function(todo){var callback=ival(todo,'callback'),that=this;if((typeof(callback)==='function')&&todo.options){todo.options.origin=toLatLng(todo.options.origin,true);todo.options.destination=toLatLng(todo.options.destination,true);getDirectionsService().route(todo.options,function(results,status){var out=status==google.maps.DirectionsStatus.OK?results:false;callback.apply($this,[out,status]);that._end()})}else{this._end()}}this.getelevation=function(todo){var fnc,path,samples,i,locations=[],callback=ival(todo,'callback'),latLng=ival(todo,'latlng'),that=this;if(typeof(callback)==='function'){fnc=function(results,status){var out=status===google.maps.ElevationStatus.OK?results:false;callback.apply($this,[out,status]);that._end()};if(latLng){locations.push(toLatLng(latLng))}else{locations=ival(todo,'locations')||[];if(locations){locations=array(locations);for(i=0;i<locations.length;i++){locations[i]=toLatLng(locations[i])}}}if(locations.length){getElevationService().getElevationForLocations({locations:locations},fnc)}else{path=ival(todo,'path');samples=ival(todo,'samples');if(path&&samples){for(i=0;i<path.length;i++){locations.push(toLatLng(path[i]))}if(locations.length){getElevationService().getElevationAlongPath({path:locations,samples:samples},fnc)}}}}else{this._end()}}this.getdistance=function(todo){var i,callback=ival(todo,'callback'),that=this;if((typeof(callback)==='function')&&todo.options&&todo.options.origins&&todo.options.destinations){todo.options.origins=array(todo.options.origins);for(i=0;i<todo.options.origins.length;i++){todo.options.origins[i]=toLatLng(todo.options.origins[i],true)}todo.options.destinations=array(todo.options.destinations);for(i=0;i<todo.options.destinations.length;i++){todo.options.destinations[i]=toLatLng(todo.options.destinations[i],true)}getDistanceMatrixService().getDistanceMatrix(todo.options,function(results,status){var out=status==google.maps.DistanceMatrixStatus.OK?results:false;callback.apply($this,[out,status]);that._end()})}else{this._end()}}this.addmarker=function(todo){this._resolveLatLng(todo,'_addMarker')}this._addMarker=function(todo,latLng,internal){var result,oi,to,o=getObject('marker',todo,'to');if(!internal){if(!latLng){this._manageEnd(false,o);return}this._subcall(todo,latLng)}else if(!latLng){return}if(o.to){to=store.refToObj(o.to);result=to&&(typeof(to.add)==='function');if(result){to.add(latLng,todo);if(typeof(to.redraw)==='function'){to.redraw()}}if(!internal){this._manageEnd(result,o)}}else{o.options.position=latLng;o.options.map=map;result=new _default.classes.Marker(o.options);if(hasKey(todo,'infowindow')){oi=getObject('infowindow',todo['infowindow'],'open');if((oi.open===undefined)||oi.open){oi.apply=array(oi.apply);oi.apply.unshift({action:'open',args:[map,result]})}oi.action='addinfowindow';this._planNext(oi)}if(!internal){store.add('marker',result,o);this._manageEnd(result,o)}}return result}this.addmarkers=function(todo){if(ival(todo,'clusters')){this._resolveAllLatLng(todo,'markers','_addclusteredmarkers')}else{this._resolveAllLatLng(todo,'markers','_addmarkers')}}this._addmarkers=function(todo){var result,o,i,latLng,marker,options={},tmp,to,markers=ival(todo,'markers');this._subcall(todo);if(typeof(markers)!=='object'){return this._end()}o=getObject('marker',todo,['to','markers']);if(o.to){to=store.refToObj(o.to);result=to&&(typeof(to.add)==='function');if(result){for(i=0;i<markers.length;i++){if(latLng=toLatLng(markers[i])){to.add(latLng,markers[i])}}if(typeof(to.redraw)==='function'){to.redraw()}}this._manageEnd(result,o)}else{$.extend(true,options,o.options);options.map=map;result=[];for(i=0;i<markers.length;i++){if(latLng=toLatLng(markers[i])){if(markers[i].options){tmp={};$.extend(true,tmp,options,markers[i].options);o.options=tmp}else{o.options=options}o.options.position=latLng;marker=new _default.classes.Marker(o.options);result.push(marker);o.data=markers[i].data;o.tag=markers[i].tag;store.add('marker',marker,o);this._manageEnd(marker,o,true)}}o.options=options;this._callback(result,todo);this._end()}}this._addclusteredmarkers=function(todo){var clusterer,i,latLng,storeId,that=this,radius=ival(todo,'radius'),maxZoom=ival(todo,'maxZoom'),markers=ival(todo,'markers'),styles=ival(todo,'clusters');if(!map.getBounds()){google.maps.event.addListenerOnce(map,'bounds_changed',function(){that._addclusteredmarkers(todo)});return}if(typeof(radius)==='number'){clusterer=new Clusterer();for(i=0;i<markers.length;i++){latLng=toLatLng(markers[i]);clusterer.add(latLng,markers[i])}storeId=this._initClusters(todo,clusterer,radius,maxZoom,styles)}this._callback(storeId,todo);this._end()}this._initClusters=function(todo,clusterer,radius,maxZoom,styles){var that=this;clusterer.setRedraw(function(force){var same,clusters=clusterer.clusters(map,radius,maxZoom,force);if(clusters){same=clusterer.freeDiff(clusters);that._displayClusters(todo,clusterer,clusters,same,styles)}});clusterer.events(google.maps.event.addListener(map,'zoom_changed',function(){clusterer.redraw(true)}),google.maps.event.addListener(map,'bounds_changed',function(){clusterer.redraw()}));clusterer.redraw();return store.add('cluster',clusterer,todo)}this._displayClusters=function(todo,clusterer,clusters,same,styles){var k,i,ii,m,done,obj,shadow,cluster,options,tmp,w,h,atodo,offset,ctodo=hasKey(todo,'cluster')?getObject('',ival(todo,'cluster')):{},mtodo=hasKey(todo,'marker')?getObject('',ival(todo,'marker')):{};for(i=0;i<clusters.length;i++){if(i in same){continue}cluster=clusters[i];done=false;if(cluster.idx.length>1){m=0;for(k in styles){if((k>m)&&(k<=cluster.idx.length)){m=k}}if(styles[m]){w=ival(styles[m],'width');h=ival(styles[m],'height');offset=ival(styles[m],'offset')||[-w/2,-h/2];atodo={};$.extend(true,atodo,ctodo,{options:{pane:'overlayLayer',content:styles[m].content.replace('CLUSTER_COUNT',cluster.idx.length),offset:{x:offset[0],y:offset[1]}}});obj=this._addOverlay(atodo,toLatLng(cluster),true);atodo.options.pane='floatShadow';atodo.options.content=$('<div></div>');atodo.options.content.width(w);atodo.options.content.height(h);shadow=this._addOverlay(atodo,toLatLng(cluster),true);ctodo.data={latLng:toLatLng(cluster),markers:[]};for(ii=0;ii<cluster.idx.length;ii++){ctodo.data.markers.push(clusterer.get(cluster.idx[ii]).marker)}this._attachEvents(shadow,ctodo);clusterer.store(cluster,obj,shadow);done=true}}if(!done){options={};$.extend(true,options,mtodo.options);for(ii=0;ii<cluster.idx.length;ii++){m=clusterer.get(cluster.idx[ii]);mtodo.latLng=m.latLng;mtodo.data=m.marker.data;mtodo.tag=m.marker.tag;if(m.marker.options){tmp={};$.extend(true,tmp,options,m.marker.options);mtodo.options=tmp}else{mtodo.options=options}obj=this._addMarker(mtodo,mtodo.latLng,true);this._attachEvents(obj,mtodo);clusterer.store(cluster,obj)}mtodo.options=options}}}this.addinfowindow=function(todo){this._resolveLatLng(todo,'_addInfoWindow')}this._addInfoWindow=function(todo,latLng){var o,infowindow,args=[];this._subcall(todo,latLng);o=getObject('infowindow',todo,['open','anchor']);if(latLng){o.options.position=latLng}infowindow=new _default.classes.InfoWindow(o.options);if((o.open===undefined)||o.open){o.apply=array(o.apply);args.push(map);if(o.anchor){args.push(o.anchor)}o.apply.unshift({action:'open',args:args})}store.add('infowindow',infowindow,o);this._manageEnd(infowindow,o)}this.addpolyline=function(todo){this._addPoly(todo,'Polyline','path')}this.addpolygon=function(todo){this._addPoly(todo,'Polygon','paths')}this._addPoly=function(todo,poly,path){var i,obj,latLng,o=getObject(poly.toLowerCase(),todo,path);if(o[path]){o.options[path]=[];for(i=0;i<o[path].length;i++){if(latLng=toLatLng(o[path][i])){o.options[path].push(latLng)}}}obj=new google.maps[poly](o.options);obj.setMap(map);store.add(poly.toLowerCase(),obj,o);this._manageEnd(obj,o)}this.addcircle=function(todo){this._resolveLatLng(todo,'_addCircle')}this._addCircle=function(todo,latLng){var c,o=getObject('circle',todo);if(!latLng){latLng=toLatLng(o.options.center)}if(!latLng){return this._manageEnd(false,o)}this._subcall(todo,latLng);o.options.center=latLng;o.options.map=map;c=new _default.classes.Circle(o.options);store.add('circle',c,o);this._manageEnd(c,o)}this.addrectangle=function(todo){this._resolveLatLng(todo,'_addRectangle')}this._addRectangle=function(todo,latLng){var r,o=getObject('rectangle',todo);o.options.bounds=toLatLngBounds(o.options.bounds,true);if(!o.options.bounds){return this._manageEnd(false,o)}this._subcall(todo,o.options.bounds.getCenter());o.options.map=map;r=new _default.classes.Rectangle(o.options);store.add('rectangle',r,o);this._manageEnd(r,o)}this.addoverlay=function(todo){this._resolveLatLng(todo,'_addOverlay')}this._addOverlay=function(todo,latLng,internal){var ov,o=getObject('overlay',todo),opts=$.extend({pane:'floatPane',content:'',offset:{x:0,y:0}},o.options),$div=$('<div></div>'),listeners=[];$div.css('border','none').css('borderWidth','0px').css('position','absolute');$div.append(opts.content);function f(){_default.classes.OverlayView.call(this);this.setMap(map)}f.prototype=new _default.classes.OverlayView();f.prototype.onAdd=function(){var panes=this.getPanes();if(opts.pane in panes){$(panes[opts.pane]).append($div)}}f.prototype.draw=function(){var overlayProjection=this.getProjection(),ps=overlayProjection.fromLatLngToDivPixel(latLng),that=this;$div.css('left',(ps.x+opts.offset.x)+'px').css('top',(ps.y+opts.offset.y)+'px');$.each(("dblclick click mouseover mousemove mouseout mouseup mousedown").split(" "),function(i,name){listeners.push(google.maps.event.addDomListener($div[0],name,function(e){google.maps.event.trigger(that,name)}))});listeners.push(google.maps.event.addDomListener($div[0],"contextmenu",function(e){google.maps.event.trigger(that,"rightclick")}))}f.prototype.onRemove=function(){for(var i=0;i<listeners.length;i++){google.maps.event.removeListener(listeners[i])}$div.remove()}f.prototype.hide=function(){$div.hide()}f.prototype.show=function(){$div.show()}f.prototype.toggle=function(){if($div){if($div.is(':visible')){this.show()}else{this.hide()}}}f.prototype.toggleDOM=function(){if(this.getMap()){this.setMap(null)}else{this.setMap(map)}}f.prototype.getDOMElement=function(){return $div[0]}ov=new f();if(!internal){store.add('overlay',ov,o);this._manageEnd(ov,o)}return ov}this.addfixpanel=function(todo){var o=getObject('fixpanel',todo),x=y=0,$c,$div;if(o.options.content){$c=$(o.options.content);if(o.options.left!==undefined){x=o.options.left}else if(o.options.right!==undefined){x=$this.width()-$c.width()-o.options.right}else if(o.options.center){x=($this.width()-$c.width())/2}if(o.options.top!==undefined){y=o.options.top}else if(o.options.bottom!==undefined){y=$this.height()-$c.height()-o.options.bottom}else if(o.options.middle){y=($this.height()-$c.height())/2}$div=$('<div></div>').css('position','absolute').css('top',y+'px').css('left',x+'px').css('z-index','1000').append($c);$this.first().prepend($div);this._attachEvents(map,o);store.add('fixpanel',$div,o);this._callback($div,o)}this._end()}this.adddirectionsrenderer=function(todo,internal){var dr,o=getObject('directionrenderer',todo,'panelId');o.options.map=map;dr=new google.maps.DirectionsRenderer(o.options);if(o.panelId){dr.setPanel(document.getElementById(o.panelId))}store.add('directionrenderer',dr,o);this._manageEnd(dr,o,internal);return dr}this.setdirectionspanel=function(todo){var dr=store.get('directionrenderer'),o=getObject('directionpanel',todo,'id');if(dr&&o.id){dr.setPanel(document.getElementById(o.id))}this._manageEnd(dr,o)}this.setdirections=function(todo){var dr=store.get('directionrenderer'),o=getObject('directions',todo);if(todo){o.options.directions=todo.directions?todo.directions:(todo.options&&todo.options.directions?todo.options.directions:null)}if(o.options.directions){if(!dr){dr=this.adddirectionsrenderer(o,true)}else{dr.setDirections(o.options.directions)}}this._manageEnd(dr,o)}this.setstreetview=function(todo){var panorama,o=getObject('streetview',todo,'id');if(o.options.position){o.options.position=toLatLng(o.options.position)}panorama=new _default.classes.StreetViewPanorama(document.getElementById(o.id),o.options);if(panorama){map.setStreetView(panorama)}this._manageEnd(panorama,o)}this.addkmllayer=function(todo){var kml,o=getObject('kmllayer',todo,'url');o.options.map=map;if(typeof(o.url)==='string'){kml=new _default.classes.KmlLayer(o.url,o.options)}store.add('kmllayer',kml,o);this._manageEnd(kml,o)}this.addtrafficlayer=function(todo){var o=getObject('trafficlayer',todo),tl=store.get('trafficlayer');if(!tl){tl=new _default.classes.TrafficLayer();tl.setMap(map);store.add('trafficlayer',tl,o)}this._manageEnd(tl,o)}this.addbicyclinglayer=function(todo){var o=getObject('bicyclinglayer',todo),bl=store.get('bicyclinglayer');if(!bl){bl=new _default.classes.BicyclingLayer();bl.setMap(map);store.add('bicyclinglayer',bl,o)}this._manageEnd(bl,o)}this.addgroundoverlay=function(todo){var ov,o=getObject('groundoverlay',todo,['bounds','url']);o.bounds=toLatLngBounds(o.bounds);if(o.bounds&&(typeof(o.url)==='string')){ov=new _default.classes.GroundOverlay(o.url,o.bounds);ov.setMap(map);store.add('groundoverlay',ov,o)}this._manageEnd(ov,o)}this.geolatlng=function(todo){var callback=ival(todo,'callback');if(typeof(callback)==='function'){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){var out=new google.maps.LatLng(position.coords.latitude,position.coords.longitude);callback.apply($this,[out])},function(){var out=false;callback.apply($this,[out])})}else if(google.gears){google.gears.factory.create('beta.geolocation').getCurrentPosition(function(position){var out=new google.maps.LatLng(position.latitude,position.longitude);callback.apply($this,[out])},function(){out=false;callback.apply($this,[out])})}else{callback.apply($this,[false])}}this._end()}this.addstyledmap=function(todo,internal){var o=getObject('styledmap',todo,['id','style']);if(o.style&&o.id&&!styles[o.id]){styles[o.id]=new _default.classes.StyledMapType(o.style,o.options);if(map){map.mapTypes.set(o.id,styles[o.id])}}this._manageEnd(styles[o.id],o,internal)}this.setstyledmap=function(todo){var o=getObject('styledmap',todo,['id','style']);if(o.id){this.addstyledmap(o,true);if(styles[o.id]){map.setMapTypeId(o.id);this._callback(styles[o.id],todo)}}this._manageEnd(styles[o.id],o)}this.clear=function(todo){var list=array(ival(todo,'list')||ival(todo,'name')),last=ival(todo,'last',false),first=ival(todo,'first',false),tag=ival(todo,'tag');if(tag!==undefined){tag=array(tag)}store.clear(list,last,first,tag);this._end()}this.get=function(todo){var name=ival(todo,'name')||'map',first=ival(todo,'first'),all=ival(todo,'all'),tag=ival(todo,'tag');name=name.toLowerCase();if(name==='map'){return map}if(tag!==undefined){tag=array(tag)}if(first){return store.get(name,false,tag)}else if(all){return store.all(name,tag)}else{return store.get(name,true,tag)}}this.getmaxzoom=function(todo){this._resolveLatLng(todo,'_getMaxZoom')}this._getMaxZoom=function(todo,latLng){var callback=ival(todo,'callback'),that=this;if(callback&&typeof(callback)==='function'){getMaxZoomService().getMaxZoomAtLatLng(latLng,function(result){var zoom=result.status===google.maps.MaxZoomStatus.OK?result.zoom:false;callback.apply($this,[zoom,result.status]);that._end()})}else{this._end()}}this.setdefault=function(todo){setDefault(todo);this._end()}this.autofit=function(todo,internal){var names,list,obj,i,j,empty=true,bounds=new google.maps.LatLngBounds(),maxZoom=ival(todo,'maxZoom',null);names=store.names();for(i=0;i<names.length;i++){list=store.all(names[i]);for(j=0;j<list.length;j++){obj=list[j];if(obj.getPosition){bounds.extend(obj.getPosition());empty=false}else if(obj.getBounds){bounds.extend(obj.getBounds().getNorthEast());bounds.extend(obj.getBounds().getSouthWest());empty=false}else if(obj.getPaths){obj.getPaths().forEach(function(path){path.forEach(function(latLng){bounds.extend(latLng);empty=false})})}else if(obj.getPath){obj.getPath().forEach(function(latLng){bounds.extend(latLng);empty=false})}else if(obj.getCenter){bounds.extend(obj.getCenter());empty=false}}}if(!empty&&(!map.getBounds()||!map.getBounds().equals(bounds))){if(maxZoom!==null){google.maps.event.addListenerOnce(map,'bounds_changed',function(){if(this.getZoom()>maxZoom){this.setZoom(maxZoom)}})}map.fitBounds(bounds)}if(!internal){this._manageEnd(empty?false:bounds,todo,internal)}}};$.fn.gmap3=function(){var i,args,list=[],empty=true,results=[];if($.isEmptyObject(_default)){_default={verbose:false,queryLimit:{attempt:5,delay:250,random:250},init:{mapTypeId:google.maps.MapTypeId.ROADMAP,center:[46.578498,2.457275],zoom:2},classes:{Map:google.maps.Map,Marker:google.maps.Marker,InfoWindow:google.maps.InfoWindow,Circle:google.maps.Circle,Rectangle:google.maps.Rectangle,OverlayView:google.maps.OverlayView,StreetViewPanorama:google.maps.StreetViewPanorama,KmlLayer:google.maps.KmlLayer,TrafficLayer:google.maps.TrafficLayer,BicyclingLayer:google.maps.BicyclingLayer,GroundOverlay:google.maps.GroundOverlay,StyledMapType:google.maps.StyledMapType}}}for(i=0;i<arguments.length;i++){args=arguments[i]||{};if(typeof(args)==='string'){args={action:args}}list.push(args)}if(!list.length){list.push({})}$.each(this,function(){var $this=$(this),gmap3=$this.data('gmap3');empty=false;if(!gmap3){gmap3=new Gmap3($this);$this.data('gmap3',gmap3)}if((list.length==1)&&(isDirect(list[0]))){results.push(gmap3._direct(list[0]))}else{gmap3._plan(list)}});if(results.length){if(results.length===1){return results[0]}else{return results}}if(empty&&(arguments.length==2)&&(typeof(arguments[0])==='string')&&(arguments[0].toLowerCase()==='setdefault')){setDefault(arguments[1])}return this}}(jQuery));

0 comments on commit c6dfe69

Please sign in to comment.