PageSourceSearch

https://redot.jp/common/js/gmaps.js

js redot.jp collected 2026-10-05 11:12:01 UTC 59,998 bytes, 2,238 lines download raw bytes

vendor: 21,428 bytes, lines 1-797
1"use strict";
2(function(root, factory) {
3  if(typeof exports === 'object') {
4    module.exports = factory();
5  }
6  else if(typeof define === 'function' && define.amd) {
7    define(['jquery', 'googlemaps!'], factory);
8  }
9  else {
10    root.GMaps = factory();
11  }
12
13
14}(this, function() {
15
16/*!
17 * GMaps.js v0.4.21
18 * http://hpneo.github.com/gmaps/
19 *
20 * Copyright 2015, Gustavo Leon
21 * Released under the MIT License.
22 */
23
24var extend_object = function(obj, new_obj) {
25  var name;
26
27  if (obj === new_obj) {
28    return obj;
29  }
30
31  for (name in new_obj) {
32    obj[name] = new_obj[name];
33  }
34
35  return obj;
36};
37
38var replace_object = function(obj, replace) {
39  var name;
40
41  if (obj === replace) {
42    return obj;
43  }
44
45  for (name in replace) {
46    if (obj[name] != undefined) {
47      obj[name] = replace[name];
48    }
49  }
50
51  return obj;
52};
53
54var array_map = function(array, callback) {
55  var original_callback_params = Array.prototype.slice.call(arguments, 2),
56      array_return = [],
57      array_length = array.length,
58      i;
59
60  if (Array.prototype.map && array.map === Array.prototype.map) {
61    array_return = Array.prototype.map.call(array, function(item) {
62      var callback_params = original_callback_params.slice(0);
63      callback_params.splice(0, 0, item);
64
65      return callback.apply(this, callback_params);
66    });
67  }
68  else {
69    for (i = 0; i < array_length; i++) {
70      callback_params = original_callback_params;
71      callback_params.splice(0, 0, array[i]);
72      array_return.push(callback.apply(this, callback_params));
73    }
74  }
75
76  return array_return;
77};
78
79var array_flat = function(array) {
80  var new_array = [],
81      i;
82
83  for (i = 0; i < array.length; i++) {
84    new_array = new_array.concat(array[i]);
85  }
86
87  return new_array;
88};
89
90var coordsToLatLngs = function(coords, useGeoJSON) {
91  var first_coord = coords[0],
92      second_coord = coords[1];
93
94  if (useGeoJSON) {
95    first_coord = coords[1];
96    second_coord = coords[0];
97  }
98
99  return new google.maps.LatLng(first_coord, second_coord);
100};
101
102var arrayToLatLng = function(coords, useGeoJSON) {
103  var i;
104
105  for (i = 0; i < coords.length; i++) {
106    if (!(coords[i] instanceof google.maps.LatLng)) {
107      if (coords[i].length > 0 && typeof(coords[i][0]) === "object") {
108        coords[i] = arrayToLatLng(coords[i], useGeoJSON);
109      }
110      else {
111        coords[i] = coordsToLatLngs(coords[i], useGeoJSON);
112      }
113    }
114  }
115
116  return coords;
117};
118
119var getElementsByClassName = function (class_name, context) {
120
121    var element,
122        _class = class_name.replace('.', '');
123
124    if ('jQuery' in this && context) {
125        element = $("." + _class, context)[0];
126    } else {
127        element = document.getElementsByClassName(_class)[0];
128    }
129    return element;
130
131};
132
133var getElementById = function(id, context) {
134  var element,
135  id = id.replace('#', '');
136
137  if ('jQuery' in window && context) {
138    element = $('#' + id, context)[0];
139  } else {
140    element = document.getElementById(id);
141  };
142
143  return element;
144};
145
146var findAbsolutePosition = function(obj)  {
147  var curleft = 0,
148      curtop = 0;
149
150  if (obj.offsetParent) {
151    do {
152      curleft += obj.offsetLeft;
153      curtop += obj.offsetTop;
154    } while (obj = obj.offsetParent);
155  }
156
157  return [curleft, curtop];
158};
159
160var GMaps = (function(global) {
161  "use strict";
162
163  if (!(typeof window.google === 'object' && window.google.maps)) {
164    if (typeof window.console === 'object' && window.console.error) {
165      console.error('Google Maps API is required. Please register the following JavaScript library https://maps.googleapis.com/maps/api/js.');
166    }
167
168    return function() {};
169  }
170
171  var doc = document;
172
173  var GMaps = function(options) {
174    if (!this) return new GMaps(options);
175
176    options.zoom = options.zoom || 15;
177    options.mapType = options.mapType || 'roadmap';
178
179    var valueOrDefault = function(value, defaultValue) {
180      return value === undefined ? defaultValue : value;
181    };
182
183    var self = this,
184        i,
185        events_that_hide_context_menu = [
186          'bounds_changed', 'center_changed', 'click', 'dblclick', 'drag',
187          'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed',
188          'resize', 'tilesloaded', 'zoom_changed'
189        ],
190        events_that_doesnt_hide_context_menu = ['mousemove', 'mouseout', 'mouseover'],
191        options_to_be_deleted = ['el', 'lat', 'lng', 'mapType', 'width', 'height', 'markerClusterer', 'enableNewStyle'],
192        identifier = options.el || options.div,
193        markerClustererFunction = options.markerClusterer,
194        mapType = google.maps.MapTypeId[options.mapType.toUpperCase()],
195        map_center = new google.maps.LatLng(options.lat, options.lng),
196        zoomControl = valueOrDefault(options.zoomControl, true),
197        zoomControlOpt = options.zoomControlOpt || {
198          style: 'DEFAULT',
199          position: 'TOP_LEFT'
200        },
201        zoomControlStyle = zoomControlOpt.style || 'DEFAULT',
202        zoomControlPosition = zoomControlOpt.position || 'TOP_LEFT',
203        panControl = valueOrDefault(options.panControl, true),
204        mapTypeControl = valueOrDefault(options.mapTypeControl, true),
205        scaleControl = valueOrDefault(options.scaleControl, true),
206        streetViewControl = valueOrDefault(options.streetViewControl, true),
207        overviewMapControl = valueOrDefault(overviewMapControl, true),
208        map_options = {},
209        map_base_options = {
210          zoom: this.zoom,
211          center: map_center,
212          mapTypeId: mapType
213        },
214        map_controls_options = {
215          panControl: panControl,
216          zoomControl: zoomControl,
217          zoomControlOptions: {
218            style: google.maps.ZoomControlStyle[zoomControlStyle],
219            position: google.maps.ControlPosition[zoomControlPosition]
220          },
221          mapTypeControl: mapTypeControl,
222          scaleControl: scaleControl,
223          streetViewControl: streetViewControl,
224          overviewMapControl: overviewMapControl
225        };
226
227      if (typeof(options.el) === 'string' || typeof(options.div) === 'string') {
228
229          if (identifier.indexOf("#") > -1) {
230              this.el = getElementById(identifier, options.context);
231          } else {
232              this.el = getElementsByClassName.apply(this, [identifier, options.context]);
233          }
234
235      } else {
236          this.el = identifier;
237      }
238
239    if (typeof(this.el) === 'undefined' || this.el === null) {
240      throw 'No element defined.';
241    }
242
243    window.context_menu = window.context_menu || {};
244    window.context_menu[self.el.id] = {};
245
246    this.controls = [];
247    this.overlays = [];
248    this.layers = []; // array with kml/georss and fusiontables layers, can be as many
249    this.singleLayers = {}; // object with the other layers, only one per layer
250    this.markers = [];
251    this.polylines = [];
252    this.routes = [];
253    this.polygons = [];
254    this.infoWindow = null;
255    this.overlay_el = null;
256    this.zoom = options.zoom;
257    this.registered_events = {};
258
259    this.el.style.width = options.width || this.el.scrollWidth || this.el.offsetWidth;
260    this.el.style.height = options.height || this.el.scrollHeight || this.el.offsetHeight;
261
262    google.maps.visualRefresh = options.enableNewStyle;
263
264    for (i = 0; i < options_to_be_deleted.length; i++) {
265      delete options[options_to_be_deleted[i]];
266    }
267
268    if(options.disableDefaultUI != true) {
269      map_base_options = extend_object(map_base_options, map_controls_options);
270    }
271
272    map_options = extend_object(map_base_options, options);
273
274    for (i = 0; i < events_that_hide_context_menu.length; i++) {
275      delete map_options[events_that_hide_context_menu[i]];
276    }
277
278    for (i = 0; i < events_that_doesnt_hide_context_menu.length; i++) {
279      delete map_options[events_that_doesnt_hide_context_menu[i]];
280    }
281
282    this.map = new google.maps.Map(this.el, map_options);
283
284    if (markerClustererFunction) {
285      this.markerClusterer = markerClustererFunction.apply(this, [this.map]);
286    }
287
288    var buildContextMenuHTML = function(control, e) {
289      var html = '',
290          options = window.context_menu[self.el.id][control];
291
292      for (var i in options){
293        if (options.hasOwnProperty(i)) {
294          var option = options[i];
295
296          html += '<li><a id="' + control + '_' + i + '" href="#">' + option.title + '</a></li>';
297        }
298      }
299
300      if (!getElementById('gmaps_context_menu')) return;
301
302      var context_menu_element = getElementById('gmaps_context_menu');
303
304      context_menu_element.innerHTML = html;
305
306      var context_menu_items = context_menu_element.getElementsByTagName('a'),
307          context_menu_items_count = context_menu_items.length,
308          i;
309
310      for (i = 0; i < context_menu_items_count; i++) {
311        var context_menu_item = context_menu_items[i];
312
313        var assign_menu_item_action = function(ev){
314          ev.preventDefault();
315
316          options[this.id.replace(control + '_', '')].action.apply(self, [e]);
317          self.hideContextMenu();
318        };
319
320        google.maps.event.clearListeners(context_menu_item, 'click');
321        google.maps.event.addDomListenerOnce(context_menu_item, 'click', assign_menu_item_action, false);
322      }
323
324      var position = findAbsolutePosition.apply(this, [self.el]),
325          left = position[0] + e.pixel.x - 15,
326          top = position[1] + e.pixel.y- 15;
327
328      context_menu_element.style.left = left + "px";
329      context_menu_element.style.top = top + "px";
330
331      // context_menu_element.style.display = 'block';
332    };
333
334    this.buildContextMenu = function(control, e) {
335      if (control === 'marker') {
336        e.pixel = {};
337
338        var overlay = new google.maps.OverlayView();
339        overlay.setMap(self.map);
340
341        overlay.draw = function() {
342          var projection = overlay.getProjection(),
343              position = e.marker.getPosition();
344
345          e.pixel = projection.fromLatLngToContainerPixel(position);
346
347          buildContextMenuHTML(control, e);
348        };
349      }
350      else {
351        buildContextMenuHTML(control, e);
352      }
353
354      var context_menu_element = getElementById('gmaps_context_menu');
355
356      setTimeout(function() {
357        context_menu_element.style.display = 'block';
358      }, 0);
359    };
360
361    this.setContextMenu = function(options) {
362      window.context_menu[self.el.id][options.control] = {};
363
364      var i,
365          ul = doc.createElement('ul');
366
367      for (i in options.options) {
368        if (options.options.hasOwnProperty(i)) {
369          var option = options.options[i];
370
371          window.context_menu[self.el.id][options.control][option.name] = {
372            title: option.title,
373            action: option.action
374          };
375        }
376      }
377
378      ul.id = 'gmaps_context_menu';
379      ul.style.display = 'none';
380      ul.style.position = 'absolute';
381      ul.style.minWidth = '100px';
382      ul.style.background = 'white';
383      ul.style.listStyle = 'none';
384      ul.style.padding = '8px';
385      ul.style.boxShadow = '2px 2px 6px #ccc';
386
387      if (!getElementById('gmaps_context_menu')) {
388        doc.body.appendChild(ul);
389      }
390
391      var context_menu_element = getElementById('gmaps_context_menu');
392
393      google.maps.event.addDomListener(context_menu_element, 'mouseout', function(ev) {
394        if (!ev.relatedTarget || !this.contains(ev.relatedTarget)) {
395          window.setTimeout(function(){
396            context_menu_element.style.display = 'none';
397          }, 400);
398        }
399      }, false);
400    };
401
402    this.hideContextMenu = function() {
403      var context_menu_element = getElementById('gmaps_context_menu');
404
405      if (context_menu_element) {
406        context_menu_element.style.display = 'none';
407      }
408    };
409
410    var setupListener = function(object, name) {
411      google.maps.event.addListener(object, name, function(e){
412        if (e == undefined) {
413          e = this;
414        }
415
416        options[name].apply(this, [e]);
417
418        self.hideContextMenu();
419      });
420    };
421
422    //google.maps.event.addListener(this.map, 'idle', this.hideContextMenu);
423    google.maps.event.addListener(this.map, 'zoom_changed', this.hideContextMenu);
424
425    for (var ev = 0; ev < events_that_hide_context_menu.length; ev++) {
426      var name = events_that_hide_context_menu[ev];
427
428      if (name in options) {
429        setupListener(this.map, name);
430      }
431    }
432
433    for (var ev = 0; ev < events_that_doesnt_hide_context_menu.length; ev++) {
434      var name = events_that_doesnt_hide_context_menu[ev];
435
436      if (name in options) {
437        setupListener(this.map, name);
438      }
439    }
440
441    google.maps.event.addListener(this.map, 'rightclick', function(e) {
442      if (options.rightclick) {
443        options.rightclick.apply(this, [e]);
444      }
445
446      if(window.context_menu[self.el.id]['map'] != undefined) {
447        self.buildContextMenu('map', e);
448      }
449    });
450
451    this.refresh = function() {
452      google.maps.event.trigger(this.map, 'resize');
453    };
454
455    this.fitZoom = function() {
456      var latLngs = [],
457          markers_length = this.markers.length,
458          i;
459
460      for (i = 0; i < markers_length; i++) {
461        if(typeof(this.markers[i].visible) === 'boolean' && this.markers[i].visible) {
462          latLngs.push(this.markers[i].getPosition());
463        }
464      }
465
466      this.fitLatLngBounds(latLngs);
467    };
468
469    this.fitLatLngBounds = function(latLngs) {
470      var total = latLngs.length,
471          bounds = new google.maps.LatLngBounds(),
472          i;
473
474      for(i = 0; i < total; i++) {
475        bounds.extend(latLngs[i]);
476      }
477
478      this.map.fitBounds(bounds);
479    };
480
481    this.setCenter = function(lat, lng, callback) {
482      this.map.panTo(new google.maps.LatLng(lat, lng));
483
484      if (callback) {
485        callback();
486      }
487    };
488
489    this.getElement = function() {
490      return this.el;
491    };
492
493    this.zoomIn = function(value) {
494      value = value || 1;
495
496      this.zoom = this.map.getZoom() + value;
497      this.map.setZoom(this.zoom);
498    };
499
500    this.zoomOut = function(value) {
501      value = value || 1;
502
503      this.zoom = this.map.getZoom() - value;
504      this.map.setZoom(this.zoom);
505    };
506
507    var native_methods = [],
508        method;
509
510    for (method in this.map) {
511      if (typeof(this.map[method]) == 'function' && !this[method]) {
512        native_methods.push(method);
513      }
514    }
515
516    for (i = 0; i < native_methods.length; i++) {
517      (function(gmaps, scope, method_name) {
518        gmaps[method_name] = function(){
519          return scope[method_name].apply(scope, arguments);
520        };
521      })(this, this.map, native_methods[i]);
522    }
523  };
524
525  return GMaps;
526})(this);
527
528GMaps.prototype.createControl = function(options) {
529  var control = document.createElement('div');
530
531  control.style.cursor = 'pointer';
532  
533  if (options.disableDefaultStyles !== true) {
534    control.style.fontFamily = 'Roboto, Arial, sans-serif';
535    control.style.fontSize = '11px';
536    control.style.boxShadow = 'rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px';
537  }
538
539  for (var option in options.style) {
540    control.style[option] = options.style[option];
541  }
542
543  if (options.id) {
544    control.id = options.id;
545  }
546  
547  if (options.title) {
548    control.title = options.title;
549  }
550
551  if (options.classes) {
552    control.className = options.classes;
553  }
554
555  if (options.content) {
556    if (typeof options.content === 'string') {
557      control.innerHTML = options.content;
558    }
559    else if (options.content instanceof HTMLElement) {
560      control.appendChild(options.content);
561    }
562  }
563
564  if (options.position) {
565    control.position = google.maps.ControlPosition[options.position.toUpperCase()];
566  }
567
568  for (var ev in options.events) {
569    (function(object, name) {
570      google.maps.event.addDomListener(object, name, function(){
571        options.events[name].apply(this, [this]);
572      });
573    })(control, ev);
574  }
575
576  control.index = 1;
577
578  return control;
579};
580
581GMaps.prototype.addControl = function(options) {
582  var control = this.createControl(options);
583  
584  this.controls.push(control);
585  this.map.controls[control.position].push(control);
586
587  return control;
588};
589
590GMaps.prototype.removeControl = function(control) {
591  var position = null,
592      i;
593
594  for (i = 0; i < this.controls.length; i++) {
595    if (this.controls[i] == control) {
596      position = this.controls[i].position;
597      this.controls.splice(i, 1);
598    }
599  }
600
601  if (position) {
602    for (i = 0; i < this.map.controls.length; i++) {
603      var controlsForPosition = this.map.controls[control.position];
604
605      if (controlsForPosition.getAt(i) == control) {
606        controlsForPosition.removeAt(i);
607
608        break;
609      }
610    }
611  }
612
613  return control;
614};
615
616GMaps.prototype.createMarker = function(options) {
617  if (options.lat == undefined && options.lng == undefined && options.position == undefined) {
618    throw 'No latitude or longitude defined.';
619  }
620
621  var self = this,
622      details = options.details,
623      fences = options.fences,
624      outside = options.outside,
625      base_options = {
626        position: new google.maps.LatLng(options.lat, options.lng),
627        map: null
628      },
629      marker_options = extend_object(base_options, options);
630
631  delete marker_options.lat;
632  delete marker_options.lng;
633  delete marker_options.fences;
634  delete marker_options.outside;
635
636  var marker = new google.maps.Marker(marker_options);
637
638  marker.fences = fences;
639
640  if (options.infoWindow) {
641    marker.infoWindow = new google.maps.InfoWindow(options.infoWindow);
642
643    var info_window_events = ['closeclick', 'content_changed', 'domready', 'position_changed', 'zindex_changed'];
644
645    for (var ev = 0; ev < info_window_events.length; ev++) {
646      (function(object, name) {
647        if (options.infoWindow[name]) {
648          google.maps.event.addListener(object, name, function(e){
649            options.infoWindow[name].apply(this, [e]);
650          });
651        }
652      })(marker.infoWindow, info_window_events[ev]);
653    }
654  }
655
656  var marker_events = ['animation_changed', 'clickable_changed', 'cursor_changed', 'draggable_changed', 'flat_changed', 'icon_changed', 'position_changed', 'shadow_changed', 'shape_changed', 'title_changed', 'visible_changed', 'zindex_changed'];
657
658  var marker_events_with_mouse = ['dblclick', 'drag', 'dragend', 'dragstart', 'mousedown', 'mouseout', 'mouseover', 'mouseup'];
659
660  for (var ev = 0; ev < marker_events.length; ev++) {
661    (function(object, name) {
662      if (options[name]) {
663        google.maps.event.addListener(object, name, function(){
664          options[name].apply(this, [this]);
665        });
666      }
667    })(marker, marker_events[ev]);
668  }
669
670  for (var ev = 0; ev < marker_events_with_mouse.length; ev++) {
671    (function(map, object, name) {
672      if (options[name]) {
673        google.maps.event.addListener(object, name, function(me){
674          if(!me.pixel){
675            me.pixel = map.getProjection().fromLatLngToPoint(me.latLng)
676          }
677          
678          options[name].apply(this, [me]);
679        });
680      }
681    })(this.map, marker, marker_events_with_mouse[ev]);
682  }
683
684  google.maps.event.addListener(marker, 'click', function() {
685    this.details = details;
686
687    if (options.click) {
688      options.click.apply(this, [this]);
689    }
690
691    if (marker.infoWindow) {
692      self.hideInfoWindows();
693      marker.infoWindow.open(self.map, marker);
694    }
695  });
696
697  google.maps.event.addListener(marker, 'rightclick', function(e) {
698    e.marker = this;
699
700    if (options.rightclick) {
701      options.rightclick.apply(this, [e]);
702    }
703
704    if (window.context_menu[self.el.id]['marker'] != undefined) {
705      self.buildContextMenu('marker', e);
706    }
707  });
708
709  if (marker.fences) {
710    google.maps.event.addListener(marker, 'dragend', function() {
711      self.checkMarkerGeofence(marker, function(m, f) {
712        outside(m, f);
713      });
714    });
715  }
716
717  return marker;
718};
719
720GMaps.prototype.addMarker = function(options) {
721  var marker;
722  if(options.hasOwnProperty('gm_accessors_')) {
723    // Native google.maps.Marker object
724    marker = options;
725  }
726  else {
727    if ((options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) || options.position) {
728      marker = this.createMarker(options);
729    }
730    else {
731      throw 'No latitude or longitude defined.';
732    }
733  }
734
735  marker.setMap(this.map);
736
737  if(this.markerClusterer) {
738    this.markerClusterer.addMarker(marker);
739  }
740
741  this.markers.push(marker);
742
743  GMaps.fire('marker_added', marker, this);
744
745  return marker;
746};
747
748GMaps.prototype.addMarkers = function(array) {
749  for (var i = 0, marker; marker=array[i]; i++) {
750    this.addMarker(marker);
751  }
752
753  return this.markers;
754};
755
756GMaps.prototype.hideInfoWindows = function() {
757  for (var i = 0, marker; marker = this.markers[i]; i++){
758    if (marker.infoWindow) {
759      marker.infoWindow.close();
760    }
761  }
762};
763
764GMaps.prototype.removeMarker = function(marker) {
765  for (var i = 0; i < this.markers.length; i++) {
766    if (this.markers[i] === marker) {
767      this.markers[i].setMap(null);
768      this.markers.splice(i, 1);
769
770      if(this.markerClusterer) {
771        this.markerClusterer.removeMarker(marker);
772      }
773
774      GMaps.fire('marker_removed', marker, this);
775
776      break;
777    }
778  }
779
780  return marker;
781};
782
783GMaps.prototype.removeMarkers = function (collection) {
784  var new_markers = [];
785
786  if (typeof collection == 'undefined') {
787    for (var i = 0; i < this.markers.length; i++) {
788      var marker = this.markers[i];
789      marker.setMap(null);
790
791      if(this.markerClusterer) {
792        this.markerClusterer.removeMarker(marker);
793      }
794
795      GMaps.fire('marker_removed', marker, this);
796    }
797    
vendor: 15,077 bytes, lines 797-1369
797
798    this.markers = new_markers;
799  }
800  else {
801    for (var i = 0; i < collection.length; i++) {
802      var index = this.markers.indexOf(collection[i]);
803
804      if (index > -1) {
805        var marker = this.markers[index];
806        marker.setMap(null);
807
808        if(this.markerClusterer) {
809          this.markerClusterer.removeMarker(marker);
810        }
811
812        GMaps.fire('marker_removed', marker, this);
813      }
814    }
815
816    for (var i = 0; i < this.markers.length; i++) {
817      var marker = this.markers[i];
818      if (marker.getMap() != null) {
819        new_markers.push(marker);
820      }
821    }
822
823    this.markers = new_markers;
824  }
825};
826
827GMaps.prototype.drawOverlay = function(options) {
828  var overlay = new google.maps.OverlayView(),
829      auto_show = true;
830
831  overlay.setMap(this.map);
832
833  if (options.auto_show != null) {
834    auto_show = options.auto_show;
835  }
836
837  overlay.onAdd = function() {
838    var el = document.createElement('div');
839
840    el.style.borderStyle = "none";
841    el.style.borderWidth = "0px";
842    el.style.position = "absolute";
843    el.style.zIndex = 100;
844    el.innerHTML = options.content;
845
846    overlay.el = el;
847
848    if (!options.layer) {
849      options.layer = 'overlayLayer';
850    }
851    
852    var panes = this.getPanes(),
853        overlayLayer = panes[options.layer],
854        stop_overlay_events = ['contextmenu', 'DOMMouseScroll', 'dblclick', 'mousedown'];
855
856    overlayLayer.appendChild(el);
857
858    for (var ev = 0; ev < stop_overlay_events.length; ev++) {
859      (function(object, name) {
860        google.maps.event.addDomListener(object, name, function(e){
861          if (navigator.userAgent.toLowerCase().indexOf('msie') != -1 && document.all) {
862            e.cancelBubble = true;
863            e.returnValue = false;
864          }
865          else {
866            e.stopPropagation();
867          }
868        });
869      })(el, stop_overlay_events[ev]);
870    }
871
872    if (options.click) {
873      panes.overlayMouseTarget.appendChild(overlay.el);
874      google.maps.event.addDomListener(overlay.el, 'click', function() {
875        options.click.apply(overlay, [overlay]);
876      });
877    }
878
879    google.maps.event.trigger(this, 'ready');
880  };
881
882  overlay.draw = function() {
883    var projection = this.getProjection(),
884        pixel = projection.fromLatLngToDivPixel(new google.maps.LatLng(options.lat, options.lng));
885
886    options.horizontalOffset = options.horizontalOffset || 0;
887    options.verticalOffset = options.verticalOffset || 0;
888
889    var el = overlay.el,
890        content = el.children[0],
891        content_height = content.clientHeight,
892        content_width = content.clientWidth;
893
894    switch (options.verticalAlign) {
895      case 'top':
896        el.style.top = (pixel.y - content_height + options.verticalOffset) + 'px';
897        break;
898      default:
899      case 'middle':
900        el.style.top = (pixel.y - (content_height / 2) + options.verticalOffset) + 'px';
901        break;
902      case 'bottom':
903        el.style.top = (pixel.y + options.verticalOffset) + 'px';
904        break;
905    }
906
907    switch (options.horizontalAlign) {
908      case 'left':
909        el.style.left = (pixel.x - content_width + options.horizontalOffset) + 'px';
910        break;
911      default:
912      case 'center':
913        el.style.left = (pixel.x - (content_width / 2) + options.horizontalOffset) + 'px';
914        break;
915      case 'right':
916        el.style.left = (pixel.x + options.horizontalOffset) + 'px';
917        break;
918    }
919
920    el.style.display = auto_show ? 'block' : 'none';
921
922    if (!auto_show) {
923      options.show.apply(this, [el]);
924    }
925  };
926
927  overlay.onRemove = function() {
928    var el = overlay.el;
929
930    if (options.remove) {
931      options.remove.apply(this, [el]);
932    }
933    else {
934      overlay.el.parentNode.removeChild(overlay.el);
935      overlay.el = null;
936    }
937  };
938
939  this.overlays.push(overlay);
940  return overlay;
941};
942
943GMaps.prototype.removeOverlay = function(overlay) {
944  for (var i = 0; i < this.overlays.length; i++) {
945    if (this.overlays[i] === overlay) {
946      this.overlays[i].setMap(null);
947      this.overlays.splice(i, 1);
948
949      break;
950    }
951  }
952};
953
954GMaps.prototype.removeOverlays = function() {
955  for (var i = 0, item; item = this.overlays[i]; i++) {
956    item.setMap(null);
957  }
958
959  this.overlays = [];
960};
961
962GMaps.prototype.drawPolyline = function(options) {
963  var path = [],
964      points = options.path;
965
966  if (points.length) {
967    if (points[0][0] === undefined) {
968      path = points;
969    }
970    else {
971      for (var i = 0, latlng; latlng = points[i]; i++) {
972        path.push(new google.maps.LatLng(latlng[0], latlng[1]));
973      }
974    }
975  }
976
977  var polyline_options = {
978    map: this.map,
979    path: path,
980    strokeColor: options.strokeColor,
981    strokeOpacity: options.strokeOpacity,
982    strokeWeight: options.strokeWeight,
983    geodesic: options.geodesic,
984    clickable: true,
985    editable: false,
986    visible: true
987  };
988
989  if (options.hasOwnProperty("clickable")) {
990    polyline_options.clickable = options.clickable;
991  }
992
993  if (options.hasOwnProperty("editable")) {
994    polyline_options.editable = options.editable;
995  }
996
997  if (options.hasOwnProperty("icons")) {
998    polyline_options.icons = options.icons;
999  }
1000
1001  if (options.hasOwnProperty("zIndex")) {
1002    polyline_options.zIndex = options.zIndex;
1003  }
1004
1005  var polyline = new google.maps.Polyline(polyline_options);
1006
1007  var polyline_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
1008
1009  for (var ev = 0; ev < polyline_events.length; ev++) {
1010    (function(object, name) {
1011      if (options[name]) {
1012        google.maps.event.addListener(object, name, function(e){
1013          options[name].apply(this, [e]);
1014        });
1015      }
1016    })(polyline, polyline_events[ev]);
1017  }
1018
1019  this.polylines.push(polyline);
1020
1021  GMaps.fire('polyline_added', polyline, this);
1022
1023  return polyline;
1024};
1025
1026GMaps.prototype.removePolyline = function(polyline) {
1027  for (var i = 0; i < this.polylines.length; i++) {
1028    if (this.polylines[i] === polyline) {
1029      this.polylines[i].setMap(null);
1030      this.polylines.splice(i, 1);
1031
1032      GMaps.fire('polyline_removed', polyline, this);
1033
1034      break;
1035    }
1036  }
1037};
1038
1039GMaps.prototype.removePolylines = function() {
1040  for (var i = 0, item; item = this.polylines[i]; i++) {
1041    item.setMap(null);
1042  }
1043
1044  this.polylines = [];
1045};
1046
1047GMaps.prototype.drawCircle = function(options) {
1048  options =  extend_object({
1049    map: this.map,
1050    center: new google.maps.LatLng(options.lat, options.lng)
1051  }, options);
1052
1053  delete options.lat;
1054  delete options.lng;
1055
1056  var polygon = new google.maps.Circle(options),
1057      polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
1058
1059  for (var ev = 0; ev < polygon_events.length; ev++) {
1060    (function(object, name) {
1061      if (options[name]) {
1062        google.maps.event.addListener(object, name, function(e){
1063          options[name].apply(this, [e]);
1064        });
1065      }
1066    })(polygon, polygon_events[ev]);
1067  }
1068
1069  this.polygons.push(polygon);
1070
1071  return polygon;
1072};
1073
1074GMaps.prototype.drawRectangle = function(options) {
1075  options = extend_object({
1076    map: this.map
1077  }, options);
1078
1079  var latLngBounds = new google.maps.LatLngBounds(
1080    new google.maps.LatLng(options.bounds[0][0], options.bounds[0][1]),
1081    new google.maps.LatLng(options.bounds[1][0], options.bounds[1][1])
1082  );
1083
1084  options.bounds = latLngBounds;
1085
1086  var polygon = new google.maps.Rectangle(options),
1087      polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
1088
1089  for (var ev = 0; ev < polygon_events.length; ev++) {
1090    (function(object, name) {
1091      if (options[name]) {
1092        google.maps.event.addListener(object, name, function(e){
1093          options[name].apply(this, [e]);
1094        });
1095      }
1096    })(polygon, polygon_events[ev]);
1097  }
1098
1099  this.polygons.push(polygon);
1100
1101  return polygon;
1102};
1103
1104GMaps.prototype.drawPolygon = function(options) {
1105  var useGeoJSON = false;
1106
1107  if(options.hasOwnProperty("useGeoJSON")) {
1108    useGeoJSON = options.useGeoJSON;
1109  }
1110
1111  delete options.useGeoJSON;
1112
1113  options = extend_object({
1114    map: this.map
1115  }, options);
1116
1117  if (useGeoJSON == false) {
1118    options.paths = [options.paths.slice(0)];
1119  }
1120
1121  if (options.paths.length > 0) {
1122    if (options.paths[0].length > 0) {
1123      options.paths = array_flat(array_map(options.paths, arrayToLatLng, useGeoJSON));
1124    }
1125  }
1126
1127  var polygon = new google.maps.Polygon(options),
1128      polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
1129
1130  for (var ev = 0; ev < polygon_events.length; ev++) {
1131    (function(object, name) {
1132      if (options[name]) {
1133        google.maps.event.addListener(object, name, function(e){
1134          options[name].apply(this, [e]);
1135        });
1136      }
1137    })(polygon, polygon_events[ev]);
1138  }
1139
1140  this.polygons.push(polygon);
1141
1142  GMaps.fire('polygon_added', polygon, this);
1143
1144  return polygon;
1145};
1146
1147GMaps.prototype.removePolygon = function(polygon) {
1148  for (var i = 0; i < this.polygons.length; i++) {
1149    if (this.polygons[i] === polygon) {
1150      this.polygons[i].setMap(null);
1151      this.polygons.splice(i, 1);
1152
1153      GMaps.fire('polygon_removed', polygon, this);
1154
1155      break;
1156    }
1157  }
1158};
1159
1160GMaps.prototype.removePolygons = function() {
1161  for (var i = 0, item; item = this.polygons[i]; i++) {
1162    item.setMap(null);
1163  }
1164
1165  this.polygons = [];
1166};
1167
1168GMaps.prototype.getFromFusionTables = function(options) {
1169  var events = options.events;
1170
1171  delete options.events;
1172
1173  var fusion_tables_options = options,
1174      layer = new google.maps.FusionTablesLayer(fusion_tables_options);
1175
1176  for (var ev in events) {
1177    (function(object, name) {
1178      google.maps.event.addListener(object, name, function(e) {
1179        events[name].apply(this, [e]);
1180      });
1181    })(layer, ev);
1182  }
1183
1184  this.layers.push(layer);
1185
1186  return layer;
1187};
1188
1189GMaps.prototype.loadFromFusionTables = function(options) {
1190  var layer = this.getFromFusionTables(options);
1191  layer.setMap(this.map);
1192
1193  return layer;
1194};
1195
1196GMaps.prototype.getFromKML = function(options) {
1197  var url = options.url,
1198      events = options.events;
1199
1200  delete options.url;
1201  delete options.events;
1202
1203  var kml_options = options,
1204      layer = new google.maps.KmlLayer(url, kml_options);
1205
1206  for (var ev in events) {
1207    (function(object, name) {
1208      google.maps.event.addListener(object, name, function(e) {
1209        events[name].apply(this, [e]);
1210      });
1211    })(layer, ev);
1212  }
1213
1214  this.layers.push(layer);
1215
1216  return layer;
1217};
1218
1219GMaps.prototype.loadFromKML = function(options) {
1220  var layer = this.getFromKML(options);
1221  layer.setMap(this.map);
1222
1223  return layer;
1224};
1225
1226GMaps.prototype.addLayer = function(layerName, options) {
1227  //var default_layers = ['weather', 'clouds', 'traffic', 'transit', 'bicycling', 'panoramio', 'places'];
1228  options = options || {};
1229  var layer;
1230
1231  switch(layerName) {
1232    case 'weather': this.singleLayers.weather = layer = new google.maps.weather.WeatherLayer();
1233      break;
1234    case 'clouds': this.singleLayers.clouds = layer = new google.maps.weather.CloudLayer();
1235      break;
1236    case 'traffic': this.singleLayers.traffic = layer = new google.maps.TrafficLayer();
1237      break;
1238    case 'transit': this.singleLayers.transit = layer = new google.maps.TransitLayer();
1239      break;
1240    case 'bicycling': this.singleLayers.bicycling = layer = new google.maps.BicyclingLayer();
1241      break;
1242    case 'panoramio':
1243        this.singleLayers.panoramio = layer = new google.maps.panoramio.PanoramioLayer();
1244        layer.setTag(options.filter);
1245        delete options.filter;
1246
1247        //click event
1248        if (options.click) {
1249          google.maps.event.addListener(layer, 'click', function(event) {
1250            options.click(event);
1251            delete options.click;
1252          });
1253        }
1254      break;
1255      case 'places':
1256        this.singleLayers.places = layer = new google.maps.places.PlacesService(this.map);
1257
1258        //search, nearbySearch, radarSearch callback, Both are the same
1259        if (options.search || options.nearbySearch || options.radarSearch) {
1260          var placeSearchRequest  = {
1261            bounds : options.bounds || null,
1262            keyword : options.keyword || null,
1263            location : options.location || null,
1264            name : options.name || null,
1265            radius : options.radius || null,
1266            rankBy : options.rankBy || null,
1267            types : options.types || null
1268          };
1269
1270          if (options.radarSearch) {
1271            layer.radarSearch(placeSearchRequest, options.radarSearch);
1272          }
1273
1274          if (options.search) {
1275            layer.search(placeSearchRequest, options.search);
1276          }
1277
1278          if (options.nearbySearch) {
1279            layer.nearbySearch(placeSearchRequest, options.nearbySearch);
1280          }
1281        }
1282
1283        //textSearch callback
1284        if (options.textSearch) {
1285          var textSearchRequest  = {
1286            bounds : options.bounds || null,
1287            location : options.location || null,
1288            query : options.query || null,
1289            radius : options.radius || null
1290          };
1291
1292          layer.textSearch(textSearchRequest, options.textSearch);
1293        }
1294      break;
1295  }
1296
1297  if (layer !== undefined) {
1298    if (typeof layer.setOptions == 'function') {
1299      layer.setOptions(options);
1300    }
1301    if (typeof layer.setMap == 'function') {
1302      layer.setMap(this.map);
1303    }
1304
1305    return layer;
1306  }
1307};
1308
1309GMaps.prototype.removeLayer = function(layer) {
1310  if (typeof(layer) == "string" && this.singleLayers[layer] !== undefined) {
1311     this.singleLayers[layer].setMap(null);
1312
1313     delete this.singleLayers[layer];
1314  }
1315  else {
1316    for (var i = 0; i < this.layers.length; i++) {
1317      if (this.layers[i] === layer) {
1318        this.layers[i].setMap(null);
1319        this.layers.splice(i, 1);
1320
1321        break;
1322      }
1323    }
1324  }
1325};
1326
1327var travelMode, unitSystem;
1328
1329GMaps.prototype.getRoutes = function(options) {
1330  switch (options.travelMode) {
1331    case 'bicycling':
1332      travelMode = google.maps.TravelMode.BICYCLING;
1333      break;
1334    case 'transit':
1335      travelMode = google.maps.TravelMode.TRANSIT;
1336      break;
1337    case 'driving':
1338      travelMode = google.maps.TravelMode.DRIVING;
1339      break;
1340    default:
1341      travelMode = google.maps.TravelMode.WALKING;
1342      break;
1343  }
1344
1345  if (options.unitSystem === 'imperial') {
1346    unitSystem = google.maps.UnitSystem.IMPERIAL;
1347  }
1348  else {
1349    unitSystem = google.maps.UnitSystem.METRIC;
1350  }
1351
1352  var base_options = {
1353        avoidHighways: false,
1354        avoidTolls: false,
1355        optimizeWaypoints: false,
1356        waypoints: []
1357      },
1358      request_options =  extend_object(base_options, options);
1359
1360  request_options.origin = /string/.test(typeof options.origin) ? options.origin : new google.maps.LatLng(options.origin[0], options.origin[1]);
1361  request_options.destination = /string/.test(typeof options.destination) ? options.destination : new google.maps.LatLng(options.destination[0], options.destination[1]);
1362  request_options.travelMode = travelMode;
1363  request_options.unitSystem = unitSystem;
1364
1365  delete request_options.callback;
1366  delete request_options.error;
1367
1368  var self = this,
1369      
vendor: 23,493 bytes, lines 1369-2238
1369service = new google.maps.DirectionsService();
1370
1371  service.route(request_options, function(result, status) {
1372    if (status === google.maps.DirectionsStatus.OK) {
1373      for (var r in result.routes) {
1374        if (result.routes.hasOwnProperty(r)) {
1375          self.routes.push(result.routes[r]);
1376        }
1377      }
1378
1379      if (options.callback) {
1380        options.callback(self.routes);
1381      }
1382    }
1383    else {
1384      if (options.error) {
1385        options.error(result, status);
1386      }
1387    }
1388  });
1389};
1390
1391GMaps.prototype.removeRoutes = function() {
1392  this.routes = [];
1393};
1394
1395GMaps.prototype.getElevations = function(options) {
1396  options = extend_object({
1397    locations: [],
1398    path : false,
1399    samples : 256
1400  }, options);
1401
1402  if (options.locations.length > 0) {
1403    if (options.locations[0].length > 0) {
1404      options.locations = array_flat(array_map([options.locations], arrayToLatLng,  false));
1405    }
1406  }
1407
1408  var callback = options.callback;
1409  delete options.callback;
1410
1411  var service = new google.maps.ElevationService();
1412
1413  //location request
1414  if (!options.path) {
1415    delete options.path;
1416    delete options.samples;
1417
1418    service.getElevationForLocations(options, function(result, status) {
1419      if (callback && typeof(callback) === "function") {
1420        callback(result, status);
1421      }
1422    });
1423  //path request
1424  } else {
1425    var pathRequest = {
1426      path : options.locations,
1427      samples : options.samples
1428    };
1429
1430    service.getElevationAlongPath(pathRequest, function(result, status) {
1431     if (callback && typeof(callback) === "function") {
1432        callback(result, status);
1433      }
1434    });
1435  }
1436};
1437
1438GMaps.prototype.cleanRoute = GMaps.prototype.removePolylines;
1439
1440GMaps.prototype.drawRoute = function(options) {
1441  var self = this;
1442
1443  this.getRoutes({
1444    origin: options.origin,
1445    destination: options.destination,
1446    travelMode: options.travelMode,
1447    waypoints: options.waypoints,
1448    unitSystem: options.unitSystem,
1449    error: options.error,
1450    callback: function(e) {
1451      if (e.length > 0) {
1452        var polyline_options = {
1453          path: e[e.length - 1].overview_path,
1454          strokeColor: options.strokeColor,
1455          strokeOpacity: options.strokeOpacity,
1456          strokeWeight: options.strokeWeight
1457        };
1458
1459        if (options.hasOwnProperty("icons")) {
1460          polyline_options.icons = options.icons;
1461        }
1462
1463        self.drawPolyline(polyline_options);
1464        
1465        if (options.callback) {
1466          options.callback(e[e.length - 1]);
1467        }
1468      }
1469    }
1470  });
1471};
1472
1473GMaps.prototype.travelRoute = function(options) {
1474  if (options.origin && options.destination) {
1475    this.getRoutes({
1476      origin: options.origin,
1477      destination: options.destination,
1478      travelMode: options.travelMode,
1479      waypoints : options.waypoints,
1480      unitSystem: options.unitSystem,
1481      error: options.error,
1482      callback: function(e) {
1483        //start callback
1484        if (e.length > 0 && options.start) {
1485          options.start(e[e.length - 1]);
1486        }
1487
1488        //step callback
1489        if (e.length > 0 && options.step) {
1490          var route = e[e.length - 1];
1491          if (route.legs.length > 0) {
1492            var steps = route.legs[0].steps;
1493            for (var i = 0, step; step = steps[i]; i++) {
1494              step.step_number = i;
1495              options.step(step, (route.legs[0].steps.length - 1));
1496            }
1497          }
1498        }
1499
1500        //end callback
1501        if (e.length > 0 && options.end) {
1502           options.end(e[e.length - 1]);
1503        }
1504      }
1505    });
1506  }
1507  else if (options.route) {
1508    if (options.route.legs.length > 0) {
1509      var steps = options.route.legs[0].steps;
1510      for (var i = 0, step; step = steps[i]; i++) {
1511        step.step_number = i;
1512        options.step(step);
1513      }
1514    }
1515  }
1516};
1517
1518GMaps.prototype.drawSteppedRoute = function(options) {
1519  var self = this;
1520  
1521  if (options.origin && options.destination) {
1522    this.getRoutes({
1523      origin: options.origin,
1524      destination: options.destination,
1525      travelMode: options.travelMode,
1526      waypoints : options.waypoints,
1527      error: options.error,
1528      callback: function(e) {
1529        //start callback
1530        if (e.length > 0 && options.start) {
1531          options.start(e[e.length - 1]);
1532        }
1533
1534        //step callback
1535        if (e.length > 0 && options.step) {
1536          var route = e[e.length - 1];
1537          if (route.legs.length > 0) {
1538            var steps = route.legs[0].steps;
1539            for (var i = 0, step; step = steps[i]; i++) {
1540              step.step_number = i;
1541              var polyline_options = {
1542                path: step.path,
1543                strokeColor: options.strokeColor,
1544                strokeOpacity: options.strokeOpacity,
1545                strokeWeight: options.strokeWeight
1546              };
1547
1548              if (options.hasOwnProperty("icons")) {
1549                polyline_options.icons = options.icons;
1550              }
1551
1552              self.drawPolyline(polyline_options);
1553              options.step(step, (route.legs[0].steps.length - 1));
1554            }
1555          }
1556        }
1557
1558        //end callback
1559        if (e.length > 0 && options.end) {
1560           options.end(e[e.length - 1]);
1561        }
1562      }
1563    });
1564  }
1565  else if (options.route) {
1566    if (options.route.legs.length > 0) {
1567      var steps = options.route.legs[0].steps;
1568      for (var i = 0, step; step = steps[i]; i++) {
1569        step.step_number = i;
1570        var polyline_options = {
1571          path: step.path,
1572          strokeColor: options.strokeColor,
1573          strokeOpacity: options.strokeOpacity,
1574          strokeWeight: options.strokeWeight
1575        };
1576
1577        if (options.hasOwnProperty("icons")) {
1578          polyline_options.icons = options.icons;
1579        }
1580
1581        self.drawPolyline(polyline_options);
1582        options.step(step);
1583      }
1584    }
1585  }
1586};
1587
1588GMaps.Route = function(options) {
1589  this.origin = options.origin;
1590  this.destination = options.destination;
1591  this.waypoints = options.waypoints;
1592
1593  this.map = options.map;
1594  this.route = options.route;
1595  this.step_count = 0;
1596  this.steps = this.route.legs[0].steps;
1597  this.steps_length = this.steps.length;
1598
1599  var polyline_options = {
1600    path: new google.maps.MVCArray(),
1601    strokeColor: options.strokeColor,
1602    strokeOpacity: options.strokeOpacity,
1603    strokeWeight: options.strokeWeight
1604  };
1605
1606  if (options.hasOwnProperty("icons")) {
1607    polyline_options.icons = options.icons;
1608  }
1609
1610  this.polyline = this.map.drawPolyline(polyline_options).getPath();
1611};
1612
1613GMaps.Route.prototype.getRoute = function(options) {
1614  var self = this;
1615
1616  this.map.getRoutes({
1617    origin : this.origin,
1618    destination : this.destination,
1619    travelMode : options.travelMode,
1620    waypoints : this.waypoints || [],
1621    error: options.error,
1622    callback : function() {
1623      self.route = e[0];
1624
1625      if (options.callback) {
1626        options.callback.call(self);
1627      }
1628    }
1629  });
1630};
1631
1632GMaps.Route.prototype.back = function() {
1633  if (this.step_count > 0) {
1634    this.step_count--;
1635    var path = this.route.legs[0].steps[this.step_count].path;
1636
1637    for (var p in path){
1638      if (path.hasOwnProperty(p)){
1639        this.polyline.pop();
1640      }
1641    }
1642  }
1643};
1644
1645GMaps.Route.prototype.forward = function() {
1646  if (this.step_count < this.steps_length) {
1647    var path = this.route.legs[0].steps[this.step_count].path;
1648
1649    for (var p in path){
1650      if (path.hasOwnProperty(p)){
1651        this.polyline.push(path[p]);
1652      }
1653    }
1654    this.step_count++;
1655  }
1656};
1657
1658GMaps.prototype.checkGeofence = function(lat, lng, fence) {
1659  return fence.containsLatLng(new google.maps.LatLng(lat, lng));
1660};
1661
1662GMaps.prototype.checkMarkerGeofence = function(marker, outside_callback) {
1663  if (marker.fences) {
1664    for (var i = 0, fence; fence = marker.fences[i]; i++) {
1665      var pos = marker.getPosition();
1666      if (!this.checkGeofence(pos.lat(), pos.lng(), fence)) {
1667        outside_callback(marker, fence);
1668      }
1669    }
1670  }
1671};
1672
1673GMaps.prototype.toImage = function(options) {
1674  var options = options || {},
1675      static_map_options = {};
1676
1677  static_map_options['size'] = options['size'] || [this.el.clientWidth, this.el.clientHeight];
1678  static_map_options['lat'] = this.getCenter().lat();
1679  static_map_options['lng'] = this.getCenter().lng();
1680
1681  if (this.markers.length > 0) {
1682    static_map_options['markers'] = [];
1683    
1684    for (var i = 0; i < this.markers.length; i++) {
1685      static_map_options['markers'].push({
1686        lat: this.markers[i].getPosition().lat(),
1687        lng: this.markers[i].getPosition().lng()
1688      });
1689    }
1690  }
1691
1692  if (this.polylines.length > 0) {
1693    var polyline = this.polylines[0];
1694    
1695    static_map_options['polyline'] = {};
1696    static_map_options['polyline']['path'] = google.maps.geometry.encoding.encodePath(polyline.getPath());
1697    static_map_options['polyline']['strokeColor'] = polyline.strokeColor
1698    static_map_options['polyline']['strokeOpacity'] = polyline.strokeOpacity
1699    static_map_options['polyline']['strokeWeight'] = polyline.strokeWeight
1700  }
1701
1702  return GMaps.staticMapURL(static_map_options);
1703};
1704
1705GMaps.staticMapURL = function(options){
1706  var parameters = [],
1707      data,
1708      static_root = (location.protocol === 'file:' ? 'http:' : location.protocol ) + '//maps.googleapis.com/maps/api/staticmap';
1709
1710  if (options.url) {
1711    static_root = options.url;
1712    delete options.url;
1713  }
1714
1715  static_root += '?';
1716
1717  var markers = options.markers;
1718  
1719  delete options.markers;
1720
1721  if (!markers && options.marker) {
1722    markers = [options.marker];
1723    delete options.marker;
1724  }
1725
1726  var styles = options.styles;
1727
1728  delete options.styles;
1729
1730  var polyline = options.polyline;
1731  delete options.polyline;
1732
1733 /** Map options **/
1734  if (options.center) {
1735    parameters.push('center=' + options.center);
1736    delete options.center;
1737  }
1738  else if (options.address) {
1739    parameters.push('center=' + options.address);
1740    delete options.address;
1741  }
1742  else if (options.lat) {
1743    parameters.push(['center=', options.lat, ',', options.lng].join(''));
1744    delete options.lat;
1745    delete options.lng;
1746  }
1747  else if (options.visible) {
1748    var visible = encodeURI(options.visible.join('|'));
1749    parameters.push('visible=' + visible);
1750  }
1751
1752  var size = options.size;
1753  if (size) {
1754    if (size.join) {
1755      size = size.join('x');
1756    }
1757    delete options.size;
1758  }
1759  else {
1760    size = '630x300';
1761  }
1762  parameters.push('size=' + size);
1763
1764  if (!options.zoom && options.zoom !== false) {
1765    options.zoom = 15;
1766  }
1767
1768  var sensor = options.hasOwnProperty('sensor') ? !!options.sensor : true;
1769  delete options.sensor;
1770  parameters.push('sensor=' + sensor);
1771
1772  for (var param in options) {
1773    if (options.hasOwnProperty(param)) {
1774      parameters.push(param + '=' + options[param]);
1775    }
1776  }
1777
1778 /** Markers **/
1779  if (markers) {
1780    var marker, loc;
1781
1782    for (var i = 0; data = markers[i]; i++) {
1783      marker = [];
1784
1785      if (data.size && data.size !== 'normal') {
1786        marker.push('size:' + data.size);
1787        delete data.size;
1788      }
1789      else if (data.icon) {
1790        marker.push('icon:' + encodeURI(data.icon));
1791        delete data.icon;
1792      }
1793
1794      if (data.color) {
1795        marker.push('color:' + data.color.replace('#', '0x'));
1796        delete data.color;
1797      }
1798
1799      if (data.label) {
1800        marker.push('label:' + data.label[0].toUpperCase());
1801        delete data.label;
1802      }
1803
1804      loc = (data.address ? data.address : data.lat + ',' + data.lng);
1805      delete data.address;
1806      delete data.lat;
1807      delete data.lng;
1808
1809      for(var param in data){
1810        if (data.hasOwnProperty(param)) {
1811          marker.push(param + ':' + data[param]);
1812        }
1813      }
1814
1815      if (marker.length || i === 0) {
1816        marker.push(loc);
1817        marker = marker.join('|');
1818        parameters.push('markers=' + encodeURI(marker));
1819      }
1820      // New marker without styles
1821      else {
1822        marker = parameters.pop() + encodeURI('|' + loc);
1823        parameters.push(marker);
1824      }
1825    }
1826  }
1827
1828 /** Map Styles **/
1829  if (styles) {
1830    for (var i = 0; i < styles.length; i++) {
1831      var styleRule = [];
1832      if (styles[i].featureType){
1833        styleRule.push('feature:' + styles[i].featureType.toLowerCase());
1834      }
1835
1836      if (styles[i].elementType) {
1837        styleRule.push('element:' + styles[i].elementType.toLowerCase());
1838      }
1839
1840      for (var j = 0; j < styles[i].stylers.length; j++) {
1841        for (var p in styles[i].stylers[j]) {
1842          var ruleArg = styles[i].stylers[j][p];
1843          if (p == 'hue' || p == 'color') {
1844            ruleArg = '0x' + ruleArg.substring(1);
1845          }
1846          styleRule.push(p + ':' + ruleArg);
1847        }
1848      }
1849
1850      var rule = styleRule.join('|');
1851      if (rule != '') {
1852        parameters.push('style=' + rule);
1853      }
1854    }
1855  }
1856
1857 /** Polylines **/
1858  function parseColor(color, opacity) {
1859    if (color[0] === '#'){
1860      color = color.replace('#', '0x');
1861
1862      if (opacity) {
1863        opacity = parseFloat(opacity);
1864        opacity = Math.min(1, Math.max(opacity, 0));
1865        if (opacity === 0) {
1866          return '0x00000000';
1867        }
1868        opacity = (opacity * 255).toString(16);
1869        if (opacity.length === 1) {
1870          opacity += opacity;
1871        }
1872
1873        color = color.slice(0,8) + opacity;
1874      }
1875    }
1876    return color;
1877  }
1878
1879  if (polyline) {
1880    data = polyline;
1881    polyline = [];
1882
1883    if (data.strokeWeight) {
1884      polyline.push('weight:' + parseInt(data.strokeWeight, 10));
1885    }
1886
1887    if (data.strokeColor) {
1888      var color = parseColor(data.strokeColor, data.strokeOpacity);
1889      polyline.push('color:' + color);
1890    }
1891
1892    if (data.fillColor) {
1893      var fillcolor = parseColor(data.fillColor, data.fillOpacity);
1894      polyline.push('fillcolor:' + fillcolor);
1895    }
1896
1897    var path = data.path;
1898    if (path.join) {
1899      for (var j=0, pos; pos=path[j]; j++) {
1900        polyline.push(pos.join(','));
1901      }
1902    }
1903    else {
1904      polyline.push('enc:' + path);
1905    }
1906
1907    polyline = polyline.join('|');
1908    parameters.push('path=' + encodeURI(polyline));
1909  }
1910
1911 /** Retina support **/
1912  var dpi = window.devicePixelRatio || 1;
1913  parameters.push('scale=' + dpi);
1914
1915  parameters = parameters.join('&');
1916  return static_root + parameters;
1917};
1918
1919GMaps.prototype.addMapType = function(mapTypeId, options) {
1920  if (options.hasOwnProperty("getTileUrl") && typeof(options["getTileUrl"]) == "function") {
1921    options.tileSize = options.tileSize || new google.maps.Size(256, 256);
1922
1923    var mapType = new google.maps.ImageMapType(options);
1924
1925    this.map.mapTypes.set(mapTypeId, mapType);
1926  }
1927  else {
1928    throw "'getTileUrl' function required.";
1929  }
1930};
1931
1932GMaps.prototype.addOverlayMapType = function(options) {
1933  if (options.hasOwnProperty("getTile") && typeof(options["getTile"]) == "function") {
1934    var overlayMapTypeIndex = options.index;
1935
1936    delete options.index;
1937
1938    this.map.overlayMapTypes.insertAt(overlayMapTypeIndex, options);
1939  }
1940  else {
1941    throw "'getTile' function required.";
1942  }
1943};
1944
1945GMaps.prototype.removeOverlayMapType = function(overlayMapTypeIndex) {
1946  this.map.overlayMapTypes.removeAt(overlayMapTypeIndex);
1947};
1948
1949GMaps.prototype.addStyle = function(options) {
1950  var styledMapType = new google.maps.StyledMapType(options.styles, { name: options.styledMapName });
1951
1952  this.map.mapTypes.set(options.mapTypeId, styledMapType);
1953};
1954
1955GMaps.prototype.setStyle = function(mapTypeId) {
1956  this.map.setMapTypeId(mapTypeId);
1957};
1958
1959GMaps.prototype.createPanorama = function(streetview_options) {
1960  if (!streetview_options.hasOwnProperty('lat') || !streetview_options.hasOwnProperty('lng')) {
1961    streetview_options.lat = this.getCenter().lat();
1962    streetview_options.lng = this.getCenter().lng();
1963  }
1964
1965  this.panorama = GMaps.createPanorama(streetview_options);
1966
1967  this.map.setStreetView(this.panorama);
1968
1969  return this.panorama;
1970};
1971
1972GMaps.createPanorama = function(options) {
1973  var el = getElementById(options.el, options.context);
1974
1975  options.position = new google.maps.LatLng(options.lat, options.lng);
1976
1977  delete options.el;
1978  delete options.context;
1979  delete options.lat;
1980  delete options.lng;
1981
1982  var streetview_events = ['closeclick', 'links_changed', 'pano_changed', 'position_changed', 'pov_changed', 'resize', 'visible_changed'],
1983      streetview_options = extend_object({visible : true}, options);
1984
1985  for (var i = 0; i < streetview_events.length; i++) {
1986    delete streetview_options[streetview_events[i]];
1987  }
1988
1989  var panorama = new google.maps.StreetViewPanorama(el, streetview_options);
1990
1991  for (var i = 0; i < streetview_events.length; i++) {
1992    (function(object, name) {
1993      if (options[name]) {
1994        google.maps.event.addListener(object, name, function(){
1995          options[name].apply(this);
1996        });
1997      }
1998    })(panorama, streetview_events[i]);
1999  }
2000
2001  return panorama;
2002};
2003
2004GMaps.prototype.on = function(event_name, handler) {
2005  return GMaps.on(event_name, this, handler);
2006};
2007
2008GMaps.prototype.off = function(event_name) {
2009  GMaps.off(event_name, this);
2010};
2011
2012GMaps.prototype.once = function(event_name, handler) {
2013  return GMaps.once(event_name, this, handler);
2014};
2015
2016GMaps.custom_events = ['marker_added', 'marker_removed', 'polyline_added', 'polyline_removed', 'polygon_added', 'polygon_removed', 'geolocated', 'geolocation_failed'];
2017
2018GMaps.on = function(event_name, object, handler) {
2019  if (GMaps.custom_events.indexOf(event_name) == -1) {
2020    if(object instanceof GMaps) object = object.map; 
2021    return google.maps.event.addListener(object, event_name, handler);
2022  }
2023  else {
2024    var registered_event = {
2025      handler : handler,
2026      eventName : event_name
2027    };
2028
2029    object.registered_events[event_name] = object.registered_events[event_name] || [];
2030    object.registered_events[event_name].push(registered_event);
2031
2032    return registered_event;
2033  }
2034};
2035
2036GMaps.off = function(event_name, object) {
2037  if (GMaps.custom_events.indexOf(event_name) == -1) {
2038    if(object instanceof GMaps) object = object.map; 
2039    google.maps.event.clearListeners(object, event_name);
2040  }
2041  else {
2042    object.registered_events[event_name] = [];
2043  }
2044};
2045
2046GMaps.once = function(event_name, object, handler) {
2047  if (GMaps.custom_events.indexOf(event_name) == -1) {
2048    if(object instanceof GMaps) object = object.map;
2049    return google.maps.event.addListenerOnce(object, event_name, handler);
2050  }
2051};
2052
2053GMaps.fire = function(event_name, object, scope) {
2054  if (GMaps.custom_events.indexOf(event_name) == -1) {
2055    google.maps.event.trigger(object, event_name, Array.prototype.slice.apply(arguments).slice(2));
2056  }
2057  else {
2058    if(event_name in scope.registered_events) {
2059      var firing_events = scope.registered_events[event_name];
2060
2061      for(var i = 0; i < firing_events.length; i++) {
2062        (function(handler, scope, object) {
2063          handler.apply(scope, [object]);
2064        })(firing_events[i]['handler'], scope, object);
2065      }
2066    }
2067  }
2068};
2069
2070GMaps.geolocate = function(options) {
2071  var complete_callback = options.always || options.complete;
2072
2073  if (navigator.geolocation) {
2074    navigator.geolocation.getCurrentPosition(function(position) {
2075      options.success(position);
2076
2077      if (complete_callback) {
2078        complete_callback();
2079      }
2080    }, function(error) {
2081      options.error(error);
2082
2083      if (complete_callback) {
2084        complete_callback();
2085      }
2086    }, options.options);
2087  }
2088  else {
2089    options.not_supported();
2090
2091    if (complete_callback) {
2092      complete_callback();
2093    }
2094  }
2095};
2096
2097GMaps.geocode = function(options) {
2098  this.geocoder = new google.maps.Geocoder();
2099  var callback = options.callback;
2100  if (options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) {
2101    options.latLng = new google.maps.LatLng(options.lat, options.lng);
2102  }
2103
2104  delete options.lat;
2105  delete options.lng;
2106  delete options.callback;
2107  
2108  this.geocoder.geocode(options, function(results, status) {
2109    callback(results, status);
2110  });
2111};
2112
2113if (typeof window.google === 'object' && window.google.maps) {
2114  //==========================
2115  // Polygon containsLatLng
2116  // https://github.com/tparkin/Google-Maps-Point-in-Polygon
2117  // Poygon getBounds extension - google-maps-extensions
2118  // http://code.google.com/p/google-maps-extensions/source/browse/google.maps.Polygon.getBounds.js
2119  if (!google.maps.Polygon.prototype.getBounds) {
2120    google.maps.Polygon.prototype.getBounds = function(latLng) {
2121      var bounds = new google.maps.LatLngBounds();
2122      var paths = this.getPaths();
2123      var path;
2124
2125      for (var p = 0; p < paths.getLength(); p++) {
2126        path = paths.getAt(p);
2127        for (var i = 0; i < path.getLength(); i++) {
2128          bounds.extend(path.getAt(i));
2129        }
2130      }
2131
2132      return bounds;
2133    };
2134  }
2135
2136  if (!google.maps.Polygon.prototype.containsLatLng) {
2137    // Polygon containsLatLng - method to determine if a latLng is within a polygon
2138    google.maps.Polygon.prototype.containsLatLng = function(latLng) {
2139      // Exclude points outside of bounds as there is no way they are in the poly
2140      var bounds = this.getBounds();
2141
2142      if (bounds !== null && !bounds.contains(latLng)) {
2143        return false;
2144      }
2145
2146      // Raycast point in polygon method
2147      var inPoly = false;
2148
2149      var numPaths = this.getPaths().getLength();
2150      for (var p = 0; p < numPaths; p++) {
2151        var path = this.getPaths().getAt(p);
2152        var numPoints = path.getLength();
2153        var j = numPoints - 1;
2154
2155        for (var i = 0; i < numPoints; i++) {
2156          var vertex1 = path.getAt(i);
2157          var vertex2 = path.getAt(j);
2158
2159          if (vertex1.lng() < latLng.lng() && vertex2.lng() >= latLng.lng() || vertex2.lng() < latLng.lng() && vertex1.lng() >= latLng.lng()) {
2160            if (vertex1.lat() + (latLng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latLng.lat()) {
2161              inPoly = !inPoly;
2162            }
2163          }
2164
2165          j = i;
2166        }
2167      }
2168
2169      return inPoly;
2170    };
2171  }
2172
2173  if (!google.maps.Circle.prototype.containsLatLng) {
2174    google.maps.Circle.prototype.containsLatLng = function(latLng) {
2175      if (google.maps.geometry) {
2176        return google.maps.geometry.spherical.computeDistanceBetween(this.getCenter(), latLng) <= this.getRadius();
2177      }
2178      else {
2179        return true;
2180      }
2181    };
2182  }
2183
2184  google.maps.LatLngBounds.prototype.containsLatLng = function(latLng) {
2185    return this.contains(latLng);
2186  };
2187
2188  google.maps.Marker.prototype.setFences = function(fences) {
2189    this.fences = fences;
2190  };
2191
2192  google.maps.Marker.prototype.addFence = function(fence) {
2193    this.fences.push(fence);
2194  };
2195
2196  google.maps.Marker.prototype.getId = function() {
2197    return this['__gm_id'];
2198  };
2199}
2200
2201//==========================
2202// Array indexOf
2203// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf
2204if (!Array.prototype.indexOf) {
2205  Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
2206      "use strict";
2207      if (this == null) {
2208          throw new TypeError();
2209      }
2210      var t = Object(this);
2211      var len = t.length >>> 0;
2212      if (len === 0) {
2213          return -1;
2214      }
2215      var n = 0;
2216      if (arguments.length > 1) {
2217          n = Number(arguments[1]);
2218          if (n != n) { // shortcut for verifying if it's NaN
2219              n = 0;
2220          } else if (n != 0 && n != Infinity && n != -Infinity) {
2221              n = (n > 0 || -1) * Math.floor(Math.abs(n));
2222          }
2223      }
2224      if (n >= len) {
2225          return -1;
2226      }
2227      var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
2228      for (; k < len; k++) {
2229          if (k in t && t[k] === searchElement) {
2230              return k;
2231          }
2232      }
2233      return -1;
2234  }
2235}
2236
2237return GMaps;
2238}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.