gmapsjs 0.4.16 → 0.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8b359e813a7ebcf253690c132ff3cf368f13662
4
- data.tar.gz: e18a21de7f15af974c952f47b2d93db41e2f486d
3
+ metadata.gz: 62591e9aaa8c31f833ff34e0c7399bc321002eb4
4
+ data.tar.gz: 1ae24ce5b528b62b67c112a5205d45113b8f8efa
5
5
  SHA512:
6
- metadata.gz: 0b58bb6ec5dad864e31e629bea1473be44bc86592ce8fe9da2dca3db300182838d0f2b733895f5ac73ca7f0d775820699c6b2ff6e8cd7d40ca4ab9649efbee0b
7
- data.tar.gz: 9fdfed750adebbf152953dc27309405c499359ad856bd3ed33877dac860ff44c5077542a9b4f843370e4f149143671b49d8444eef452e7890b703b9605964a82
6
+ metadata.gz: fec00a870804dd179690bee066074f9597de84a1a8aa3a5f943d0e7faf2a4259d286a7b037ab8a5a7742436790add5549458599f678186b9e4f3e1c1eb9206f9
7
+ data.tar.gz: d3750435b2ccc82e5d1bc2244143fb1418324f5f52f85b62d1228e729d6207f96a632dca1282e33768c2652b0e6c171c426595416cd45f713fe47081a77eb4a5
@@ -1,27 +1,26 @@
1
+ "use strict";
1
2
  (function(root, factory) {
2
3
  if(typeof exports === 'object') {
3
4
  module.exports = factory();
4
5
  }
5
6
  else if(typeof define === 'function' && define.amd) {
6
- define('GMaps', [], factory);
7
+ define(['jquery', 'googlemaps!'], factory);
8
+ }
9
+ else {
10
+ root.GMaps = factory();
7
11
  }
8
12
 
9
- root.GMaps = factory();
10
13
 
11
14
  }(this, function() {
12
15
 
13
16
  /*!
14
- * GMaps.js v0.4.16
17
+ * GMaps.js v0.4.21
15
18
  * http://hpneo.github.com/gmaps/
16
19
  *
17
- * Copyright 2014, Gustavo Leon
20
+ * Copyright 2015, Gustavo Leon
18
21
  * Released under the MIT License.
19
22
  */
20
23
 
21
- if (!(typeof window.google === 'object' && window.google.maps)) {
22
- throw 'Google Maps API is required. Please register the following JavaScript library http://maps.google.com/maps/api/js?sensor=true.'
23
- }
24
-
25
24
  var extend_object = function(obj, new_obj) {
26
25
  var name;
27
26
 
@@ -60,7 +59,7 @@ var array_map = function(array, callback) {
60
59
 
61
60
  if (Array.prototype.map && array.map === Array.prototype.map) {
62
61
  array_return = Array.prototype.map.call(array, function(item) {
63
- callback_params = original_callback_params;
62
+ var callback_params = original_callback_params.slice(0);
64
63
  callback_params.splice(0, 0, item);
65
64
 
66
65
  return callback.apply(this, callback_params);
@@ -105,7 +104,7 @@ var arrayToLatLng = function(coords, useGeoJSON) {
105
104
 
106
105
  for (i = 0; i < coords.length; i++) {
107
106
  if (!(coords[i] instanceof google.maps.LatLng)) {
108
- if (coords[i].length > 0 && typeof(coords[i][0]) == "object") {
107
+ if (coords[i].length > 0 && typeof(coords[i][0]) === "object") {
109
108
  coords[i] = arrayToLatLng(coords[i], useGeoJSON);
110
109
  }
111
110
  else {
@@ -117,12 +116,26 @@ var arrayToLatLng = function(coords, useGeoJSON) {
117
116
  return coords;
118
117
  };
119
118
 
119
+ var 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
+
120
133
  var getElementById = function(id, context) {
121
134
  var element,
122
135
  id = id.replace('#', '');
123
136
 
124
- if ('jQuery' in this && context) {
125
- element = $("#" + id, context)[0];
137
+ if ('jQuery' in window && context) {
138
+ element = $('#' + id, context)[0];
126
139
  } else {
127
140
  element = document.getElementById(id);
128
141
  };
@@ -147,6 +160,14 @@ var findAbsolutePosition = function(obj) {
147
160
  var GMaps = (function(global) {
148
161
  "use strict";
149
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
+
150
171
  var doc = document;
151
172
 
152
173
  var GMaps = function(options) {
@@ -155,27 +176,35 @@ var GMaps = (function(global) {
155
176
  options.zoom = options.zoom || 15;
156
177
  options.mapType = options.mapType || 'roadmap';
157
178
 
179
+ var valueOrDefault = function(value, defaultValue) {
180
+ return value === undefined ? defaultValue : value;
181
+ };
182
+
158
183
  var self = this,
159
184
  i,
160
- events_that_hide_context_menu = ['bounds_changed', 'center_changed', 'click', 'dblclick', 'drag', 'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed', 'resize', 'tilesloaded', 'zoom_changed'],
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
+ ],
161
190
  events_that_doesnt_hide_context_menu = ['mousemove', 'mouseout', 'mouseover'],
162
191
  options_to_be_deleted = ['el', 'lat', 'lng', 'mapType', 'width', 'height', 'markerClusterer', 'enableNewStyle'],
163
- container_id = options.el || options.div,
192
+ identifier = options.el || options.div,
164
193
  markerClustererFunction = options.markerClusterer,
165
194
  mapType = google.maps.MapTypeId[options.mapType.toUpperCase()],
166
195
  map_center = new google.maps.LatLng(options.lat, options.lng),
167
- zoomControl = options.zoomControl || true,
196
+ zoomControl = valueOrDefault(options.zoomControl, true),
168
197
  zoomControlOpt = options.zoomControlOpt || {
169
198
  style: 'DEFAULT',
170
199
  position: 'TOP_LEFT'
171
200
  },
172
201
  zoomControlStyle = zoomControlOpt.style || 'DEFAULT',
173
202
  zoomControlPosition = zoomControlOpt.position || 'TOP_LEFT',
174
- panControl = options.panControl || true,
175
- mapTypeControl = options.mapTypeControl || true,
176
- scaleControl = options.scaleControl || true,
177
- streetViewControl = options.streetViewControl || true,
178
- overviewMapControl = overviewMapControl || true,
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),
179
208
  map_options = {},
180
209
  map_base_options = {
181
210
  zoom: this.zoom,
@@ -195,11 +224,17 @@ var GMaps = (function(global) {
195
224
  overviewMapControl: overviewMapControl
196
225
  };
197
226
 
198
- if (typeof(options.el) === 'string' || typeof(options.div) === 'string') {
199
- this.el = getElementById(container_id, options.context);
200
- } else {
201
- this.el = container_id;
202
- }
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
+ }
203
238
 
204
239
  if (typeof(this.el) === 'undefined' || this.el === null) {
205
240
  throw 'No element defined.';
@@ -265,7 +300,7 @@ var GMaps = (function(global) {
265
300
  if (!getElementById('gmaps_context_menu')) return;
266
301
 
267
302
  var context_menu_element = getElementById('gmaps_context_menu');
268
-
303
+
269
304
  context_menu_element.innerHTML = html;
270
305
 
271
306
  var context_menu_items = context_menu_element.getElementsByTagName('a'),
@@ -293,7 +328,7 @@ var GMaps = (function(global) {
293
328
  context_menu_element.style.left = left + "px";
294
329
  context_menu_element.style.top = top + "px";
295
330
 
296
- context_menu_element.style.display = 'block';
331
+ // context_menu_element.style.display = 'block';
297
332
  };
298
333
 
299
334
  this.buildContextMenu = function(control, e) {
@@ -302,11 +337,11 @@ var GMaps = (function(global) {
302
337
 
303
338
  var overlay = new google.maps.OverlayView();
304
339
  overlay.setMap(self.map);
305
-
340
+
306
341
  overlay.draw = function() {
307
342
  var projection = overlay.getProjection(),
308
343
  position = e.marker.getPosition();
309
-
344
+
310
345
  e.pixel = projection.fromLatLngToContainerPixel(position);
311
346
 
312
347
  buildContextMenuHTML(control, e);
@@ -315,6 +350,12 @@ var GMaps = (function(global) {
315
350
  else {
316
351
  buildContextMenuHTML(control, e);
317
352
  }
353
+
354
+ var context_menu_element = getElementById('gmaps_context_menu');
355
+
356
+ setTimeout(function() {
357
+ context_menu_element.style.display = 'block';
358
+ }, 0);
318
359
  };
319
360
 
320
361
  this.setContextMenu = function(options) {
@@ -343,9 +384,11 @@ var GMaps = (function(global) {
343
384
  ul.style.padding = '8px';
344
385
  ul.style.boxShadow = '2px 2px 6px #ccc';
345
386
 
346
- doc.body.appendChild(ul);
387
+ if (!getElementById('gmaps_context_menu')) {
388
+ doc.body.appendChild(ul);
389
+ }
347
390
 
348
- var context_menu_element = getElementById('gmaps_context_menu')
391
+ var context_menu_element = getElementById('gmaps_context_menu');
349
392
 
350
393
  google.maps.event.addDomListener(context_menu_element, 'mouseout', function(ev) {
351
394
  if (!ev.relatedTarget || !this.contains(ev.relatedTarget)) {
@@ -424,10 +467,11 @@ var GMaps = (function(global) {
424
467
  };
425
468
 
426
469
  this.fitLatLngBounds = function(latLngs) {
427
- var total = latLngs.length;
428
- var bounds = new google.maps.LatLngBounds();
470
+ var total = latLngs.length,
471
+ bounds = new google.maps.LatLngBounds(),
472
+ i;
429
473
 
430
- for(var i=0; i < total; i++) {
474
+ for(i = 0; i < total; i++) {
431
475
  bounds.extend(latLngs[i]);
432
476
  }
433
477
 
@@ -469,7 +513,7 @@ var GMaps = (function(global) {
469
513
  }
470
514
  }
471
515
 
472
- for (i=0; i < native_methods.length; i++) {
516
+ for (i = 0; i < native_methods.length; i++) {
473
517
  (function(gmaps, scope, method_name) {
474
518
  gmaps[method_name] = function(){
475
519
  return scope[method_name].apply(scope, arguments);
@@ -485,7 +529,7 @@ GMaps.prototype.createControl = function(options) {
485
529
  var control = document.createElement('div');
486
530
 
487
531
  control.style.cursor = 'pointer';
488
-
532
+
489
533
  if (options.disableDefaultStyles !== true) {
490
534
  control.style.fontFamily = 'Roboto, Arial, sans-serif';
491
535
  control.style.fontSize = '11px';
@@ -500,6 +544,10 @@ GMaps.prototype.createControl = function(options) {
500
544
  control.id = options.id;
501
545
  }
502
546
 
547
+ if (options.title) {
548
+ control.title = options.title;
549
+ }
550
+
503
551
  if (options.classes) {
504
552
  control.className = options.classes;
505
553
  }
@@ -532,6 +580,7 @@ GMaps.prototype.createControl = function(options) {
532
580
 
533
581
  GMaps.prototype.addControl = function(options) {
534
582
  var control = this.createControl(options);
583
+
535
584
  this.controls.push(control);
536
585
  this.map.controls[control.position].push(control);
537
586
 
@@ -539,9 +588,10 @@ GMaps.prototype.addControl = function(options) {
539
588
  };
540
589
 
541
590
  GMaps.prototype.removeControl = function(control) {
542
- var position = null;
591
+ var position = null,
592
+ i;
543
593
 
544
- for (var i = 0; i < this.controls.length; i++) {
594
+ for (i = 0; i < this.controls.length; i++) {
545
595
  if (this.controls[i] == control) {
546
596
  position = this.controls[i].position;
547
597
  this.controls.splice(i, 1);
@@ -550,9 +600,11 @@ GMaps.prototype.removeControl = function(control) {
550
600
 
551
601
  if (position) {
552
602
  for (i = 0; i < this.map.controls.length; i++) {
553
- var controlsForPosition = this.map.controls[control.position]
603
+ var controlsForPosition = this.map.controls[control.position];
604
+
554
605
  if (controlsForPosition.getAt(i) == control) {
555
606
  controlsForPosition.removeAt(i);
607
+
556
608
  break;
557
609
  }
558
610
  }
@@ -622,7 +674,7 @@ GMaps.prototype.createMarker = function(options) {
622
674
  if(!me.pixel){
623
675
  me.pixel = map.getProjection().fromLatLngToPoint(me.latLng)
624
676
  }
625
-
677
+
626
678
  options[name].apply(this, [me]);
627
679
  });
628
680
  }
@@ -742,7 +794,7 @@ GMaps.prototype.removeMarkers = function (collection) {
742
794
 
743
795
  GMaps.fire('marker_removed', marker, this);
744
796
  }
745
-
797
+
746
798
  this.markers = new_markers;
747
799
  }
748
800
  else {
@@ -796,7 +848,7 @@ GMaps.prototype.drawOverlay = function(options) {
796
848
  if (!options.layer) {
797
849
  options.layer = 'overlayLayer';
798
850
  }
799
-
851
+
800
852
  var panes = this.getPanes(),
801
853
  overlayLayer = panes[options.layer],
802
854
  stop_overlay_events = ['contextmenu', 'DOMMouseScroll', 'dblclick', 'mousedown'];
@@ -916,7 +968,7 @@ GMaps.prototype.drawPolyline = function(options) {
916
968
  path = points;
917
969
  }
918
970
  else {
919
- for (var i=0, latlng; latlng=points[i]; i++) {
971
+ for (var i = 0, latlng; latlng = points[i]; i++) {
920
972
  path.push(new google.maps.LatLng(latlng[0], latlng[1]));
921
973
  }
922
974
  }
@@ -1397,13 +1449,19 @@ GMaps.prototype.drawRoute = function(options) {
1397
1449
  error: options.error,
1398
1450
  callback: function(e) {
1399
1451
  if (e.length > 0) {
1400
- self.drawPolyline({
1452
+ var polyline_options = {
1401
1453
  path: e[e.length - 1].overview_path,
1402
1454
  strokeColor: options.strokeColor,
1403
1455
  strokeOpacity: options.strokeOpacity,
1404
1456
  strokeWeight: options.strokeWeight
1405
- });
1406
-
1457
+ };
1458
+
1459
+ if (options.hasOwnProperty("icons")) {
1460
+ polyline_options.icons = options.icons;
1461
+ }
1462
+
1463
+ self.drawPolyline(polyline_options);
1464
+
1407
1465
  if (options.callback) {
1408
1466
  options.callback(e[e.length - 1]);
1409
1467
  }
@@ -1432,7 +1490,7 @@ GMaps.prototype.travelRoute = function(options) {
1432
1490
  var route = e[e.length - 1];
1433
1491
  if (route.legs.length > 0) {
1434
1492
  var steps = route.legs[0].steps;
1435
- for (var i=0, step; step=steps[i]; i++) {
1493
+ for (var i = 0, step; step = steps[i]; i++) {
1436
1494
  step.step_number = i;
1437
1495
  options.step(step, (route.legs[0].steps.length - 1));
1438
1496
  }
@@ -1449,7 +1507,7 @@ GMaps.prototype.travelRoute = function(options) {
1449
1507
  else if (options.route) {
1450
1508
  if (options.route.legs.length > 0) {
1451
1509
  var steps = options.route.legs[0].steps;
1452
- for (var i=0, step; step=steps[i]; i++) {
1510
+ for (var i = 0, step; step = steps[i]; i++) {
1453
1511
  step.step_number = i;
1454
1512
  options.step(step);
1455
1513
  }
@@ -1459,7 +1517,7 @@ GMaps.prototype.travelRoute = function(options) {
1459
1517
 
1460
1518
  GMaps.prototype.drawSteppedRoute = function(options) {
1461
1519
  var self = this;
1462
-
1520
+
1463
1521
  if (options.origin && options.destination) {
1464
1522
  this.getRoutes({
1465
1523
  origin: options.origin,
@@ -1478,14 +1536,20 @@ GMaps.prototype.drawSteppedRoute = function(options) {
1478
1536
  var route = e[e.length - 1];
1479
1537
  if (route.legs.length > 0) {
1480
1538
  var steps = route.legs[0].steps;
1481
- for (var i=0, step; step=steps[i]; i++) {
1539
+ for (var i = 0, step; step = steps[i]; i++) {
1482
1540
  step.step_number = i;
1483
- self.drawPolyline({
1541
+ var polyline_options = {
1484
1542
  path: step.path,
1485
1543
  strokeColor: options.strokeColor,
1486
1544
  strokeOpacity: options.strokeOpacity,
1487
1545
  strokeWeight: options.strokeWeight
1488
- });
1546
+ };
1547
+
1548
+ if (options.hasOwnProperty("icons")) {
1549
+ polyline_options.icons = options.icons;
1550
+ }
1551
+
1552
+ self.drawPolyline(polyline_options);
1489
1553
  options.step(step, (route.legs[0].steps.length - 1));
1490
1554
  }
1491
1555
  }
@@ -1501,14 +1565,20 @@ GMaps.prototype.drawSteppedRoute = function(options) {
1501
1565
  else if (options.route) {
1502
1566
  if (options.route.legs.length > 0) {
1503
1567
  var steps = options.route.legs[0].steps;
1504
- for (var i=0, step; step=steps[i]; i++) {
1568
+ for (var i = 0, step; step = steps[i]; i++) {
1505
1569
  step.step_number = i;
1506
- self.drawPolyline({
1570
+ var polyline_options = {
1507
1571
  path: step.path,
1508
1572
  strokeColor: options.strokeColor,
1509
1573
  strokeOpacity: options.strokeOpacity,
1510
1574
  strokeWeight: options.strokeWeight
1511
- });
1575
+ };
1576
+
1577
+ if (options.hasOwnProperty("icons")) {
1578
+ polyline_options.icons = options.icons;
1579
+ }
1580
+
1581
+ self.drawPolyline(polyline_options);
1512
1582
  options.step(step);
1513
1583
  }
1514
1584
  }
@@ -1526,12 +1596,18 @@ GMaps.Route = function(options) {
1526
1596
  this.steps = this.route.legs[0].steps;
1527
1597
  this.steps_length = this.steps.length;
1528
1598
 
1529
- this.polyline = this.map.drawPolyline({
1599
+ var polyline_options = {
1530
1600
  path: new google.maps.MVCArray(),
1531
1601
  strokeColor: options.strokeColor,
1532
1602
  strokeOpacity: options.strokeOpacity,
1533
1603
  strokeWeight: options.strokeWeight
1534
- }).getPath();
1604
+ };
1605
+
1606
+ if (options.hasOwnProperty("icons")) {
1607
+ polyline_options.icons = options.icons;
1608
+ }
1609
+
1610
+ this.polyline = this.map.drawPolyline(polyline_options).getPath();
1535
1611
  };
1536
1612
 
1537
1613
  GMaps.Route.prototype.getRoute = function(options) {
@@ -1604,7 +1680,7 @@ GMaps.prototype.toImage = function(options) {
1604
1680
 
1605
1681
  if (this.markers.length > 0) {
1606
1682
  static_map_options['markers'] = [];
1607
-
1683
+
1608
1684
  for (var i = 0; i < this.markers.length; i++) {
1609
1685
  static_map_options['markers'].push({
1610
1686
  lat: this.markers[i].getPosition().lat(),
@@ -1615,7 +1691,7 @@ GMaps.prototype.toImage = function(options) {
1615
1691
 
1616
1692
  if (this.polylines.length > 0) {
1617
1693
  var polyline = this.polylines[0];
1618
-
1694
+
1619
1695
  static_map_options['polyline'] = {};
1620
1696
  static_map_options['polyline']['path'] = google.maps.geometry.encoding.encodePath(polyline.getPath());
1621
1697
  static_map_options['polyline']['strokeColor'] = polyline.strokeColor
@@ -1629,7 +1705,7 @@ GMaps.prototype.toImage = function(options) {
1629
1705
  GMaps.staticMapURL = function(options){
1630
1706
  var parameters = [],
1631
1707
  data,
1632
- static_root = 'http://maps.googleapis.com/maps/api/staticmap';
1708
+ static_root = (location.protocol === 'file:' ? 'http:' : location.protocol ) + '//maps.googleapis.com/maps/api/staticmap';
1633
1709
 
1634
1710
  if (options.url) {
1635
1711
  static_root = options.url;
@@ -1639,7 +1715,7 @@ GMaps.staticMapURL = function(options){
1639
1715
  static_root += '?';
1640
1716
 
1641
1717
  var markers = options.markers;
1642
-
1718
+
1643
1719
  delete options.markers;
1644
1720
 
1645
1721
  if (!markers && options.marker) {
@@ -1703,7 +1779,7 @@ GMaps.staticMapURL = function(options){
1703
1779
  if (markers) {
1704
1780
  var marker, loc;
1705
1781
 
1706
- for (var i=0; data=markers[i]; i++) {
1782
+ for (var i = 0; data = markers[i]; i++) {
1707
1783
  marker = [];
1708
1784
 
1709
1785
  if (data.size && data.size !== 'normal') {
@@ -1937,7 +2013,7 @@ GMaps.custom_events = ['marker_added', 'marker_removed', 'polyline_added', 'poly
1937
2013
 
1938
2014
  GMaps.on = function(event_name, object, handler) {
1939
2015
  if (GMaps.custom_events.indexOf(event_name) == -1) {
1940
- if(object instanceof GMaps) object = object.map;
2016
+ if(object instanceof GMaps) object = object.map;
1941
2017
  return google.maps.event.addListener(object, event_name, handler);
1942
2018
  }
1943
2019
  else {
@@ -1955,7 +2031,7 @@ GMaps.on = function(event_name, object, handler) {
1955
2031
 
1956
2032
  GMaps.off = function(event_name, object) {
1957
2033
  if (GMaps.custom_events.indexOf(event_name) == -1) {
1958
- if(object instanceof GMaps) object = object.map;
2034
+ if(object instanceof GMaps) object = object.map;
1959
2035
  google.maps.event.clearListeners(object, event_name);
1960
2036
  }
1961
2037
  else {
@@ -2017,97 +2093,99 @@ GMaps.geocode = function(options) {
2017
2093
  delete options.lat;
2018
2094
  delete options.lng;
2019
2095
  delete options.callback;
2020
-
2096
+
2021
2097
  this.geocoder.geocode(options, function(results, status) {
2022
2098
  callback(results, status);
2023
2099
  });
2024
2100
  };
2025
2101
 
2026
- //==========================
2027
- // Polygon containsLatLng
2028
- // https://github.com/tparkin/Google-Maps-Point-in-Polygon
2029
- // Poygon getBounds extension - google-maps-extensions
2030
- // http://code.google.com/p/google-maps-extensions/source/browse/google.maps.Polygon.getBounds.js
2031
- if (!google.maps.Polygon.prototype.getBounds) {
2032
- google.maps.Polygon.prototype.getBounds = function(latLng) {
2033
- var bounds = new google.maps.LatLngBounds();
2034
- var paths = this.getPaths();
2035
- var path;
2102
+ if (typeof window.google === 'object' && window.google.maps) {
2103
+ //==========================
2104
+ // Polygon containsLatLng
2105
+ // https://github.com/tparkin/Google-Maps-Point-in-Polygon
2106
+ // Poygon getBounds extension - google-maps-extensions
2107
+ // http://code.google.com/p/google-maps-extensions/source/browse/google.maps.Polygon.getBounds.js
2108
+ if (!google.maps.Polygon.prototype.getBounds) {
2109
+ google.maps.Polygon.prototype.getBounds = function(latLng) {
2110
+ var bounds = new google.maps.LatLngBounds();
2111
+ var paths = this.getPaths();
2112
+ var path;
2036
2113
 
2037
- for (var p = 0; p < paths.getLength(); p++) {
2038
- path = paths.getAt(p);
2039
- for (var i = 0; i < path.getLength(); i++) {
2040
- bounds.extend(path.getAt(i));
2114
+ for (var p = 0; p < paths.getLength(); p++) {
2115
+ path = paths.getAt(p);
2116
+ for (var i = 0; i < path.getLength(); i++) {
2117
+ bounds.extend(path.getAt(i));
2118
+ }
2041
2119
  }
2042
- }
2043
2120
 
2044
- return bounds;
2045
- };
2046
- }
2121
+ return bounds;
2122
+ };
2123
+ }
2047
2124
 
2048
- if (!google.maps.Polygon.prototype.containsLatLng) {
2049
- // Polygon containsLatLng - method to determine if a latLng is within a polygon
2050
- google.maps.Polygon.prototype.containsLatLng = function(latLng) {
2051
- // Exclude points outside of bounds as there is no way they are in the poly
2052
- var bounds = this.getBounds();
2125
+ if (!google.maps.Polygon.prototype.containsLatLng) {
2126
+ // Polygon containsLatLng - method to determine if a latLng is within a polygon
2127
+ google.maps.Polygon.prototype.containsLatLng = function(latLng) {
2128
+ // Exclude points outside of bounds as there is no way they are in the poly
2129
+ var bounds = this.getBounds();
2053
2130
 
2054
- if (bounds !== null && !bounds.contains(latLng)) {
2055
- return false;
2056
- }
2131
+ if (bounds !== null && !bounds.contains(latLng)) {
2132
+ return false;
2133
+ }
2057
2134
 
2058
- // Raycast point in polygon method
2059
- var inPoly = false;
2135
+ // Raycast point in polygon method
2136
+ var inPoly = false;
2060
2137
 
2061
- var numPaths = this.getPaths().getLength();
2062
- for (var p = 0; p < numPaths; p++) {
2063
- var path = this.getPaths().getAt(p);
2064
- var numPoints = path.getLength();
2065
- var j = numPoints - 1;
2138
+ var numPaths = this.getPaths().getLength();
2139
+ for (var p = 0; p < numPaths; p++) {
2140
+ var path = this.getPaths().getAt(p);
2141
+ var numPoints = path.getLength();
2142
+ var j = numPoints - 1;
2066
2143
 
2067
- for (var i = 0; i < numPoints; i++) {
2068
- var vertex1 = path.getAt(i);
2069
- var vertex2 = path.getAt(j);
2144
+ for (var i = 0; i < numPoints; i++) {
2145
+ var vertex1 = path.getAt(i);
2146
+ var vertex2 = path.getAt(j);
2070
2147
 
2071
- if (vertex1.lng() < latLng.lng() && vertex2.lng() >= latLng.lng() || vertex2.lng() < latLng.lng() && vertex1.lng() >= latLng.lng()) {
2072
- if (vertex1.lat() + (latLng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latLng.lat()) {
2073
- inPoly = !inPoly;
2148
+ if (vertex1.lng() < latLng.lng() && vertex2.lng() >= latLng.lng() || vertex2.lng() < latLng.lng() && vertex1.lng() >= latLng.lng()) {
2149
+ if (vertex1.lat() + (latLng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latLng.lat()) {
2150
+ inPoly = !inPoly;
2151
+ }
2074
2152
  }
2153
+
2154
+ j = i;
2075
2155
  }
2156
+ }
2076
2157
 
2077
- j = i;
2158
+ return inPoly;
2159
+ };
2160
+ }
2161
+
2162
+ if (!google.maps.Circle.prototype.containsLatLng) {
2163
+ google.maps.Circle.prototype.containsLatLng = function(latLng) {
2164
+ if (google.maps.geometry) {
2165
+ return google.maps.geometry.spherical.computeDistanceBetween(this.getCenter(), latLng) <= this.getRadius();
2078
2166
  }
2079
- }
2167
+ else {
2168
+ return true;
2169
+ }
2170
+ };
2171
+ }
2080
2172
 
2081
- return inPoly;
2173
+ google.maps.LatLngBounds.prototype.containsLatLng = function(latLng) {
2174
+ return this.contains(latLng);
2082
2175
  };
2083
- }
2084
2176
 
2085
- if (!google.maps.Circle.prototype.containsLatLng) {
2086
- google.maps.Circle.prototype.containsLatLng = function(latLng) {
2087
- if (google.maps.geometry) {
2088
- return google.maps.geometry.spherical.computeDistanceBetween(this.getCenter(), latLng) <= this.getRadius();
2089
- }
2090
- else {
2091
- return true;
2092
- }
2177
+ google.maps.Marker.prototype.setFences = function(fences) {
2178
+ this.fences = fences;
2093
2179
  };
2094
- }
2095
-
2096
- google.maps.LatLngBounds.prototype.containsLatLng = function(latLng) {
2097
- return this.contains(latLng);
2098
- };
2099
-
2100
- google.maps.Marker.prototype.setFences = function(fences) {
2101
- this.fences = fences;
2102
- };
2103
2180
 
2104
- google.maps.Marker.prototype.addFence = function(fence) {
2105
- this.fences.push(fence);
2106
- };
2181
+ google.maps.Marker.prototype.addFence = function(fence) {
2182
+ this.fences.push(fence);
2183
+ };
2107
2184
 
2108
- google.maps.Marker.prototype.getId = function() {
2109
- return this['__gm_id'];
2110
- };
2185
+ google.maps.Marker.prototype.getId = function() {
2186
+ return this['__gm_id'];
2187
+ };
2188
+ }
2111
2189
 
2112
2190
  //==========================
2113
2191
  // Array indexOf
@@ -2144,6 +2222,6 @@ if (!Array.prototype.indexOf) {
2144
2222
  return -1;
2145
2223
  }
2146
2224
  }
2147
-
2225
+
2148
2226
  return GMaps;
2149
- }));
2227
+ }));
@@ -1,3 +1,3 @@
1
1
  module GmapsJS
2
- VERSION = "0.4.16"
2
+ VERSION = "0.4.21"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmapsjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.4.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvaro Pereyra
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-24 00:00:00.000000000 Z
12
+ date: 2015-11-16 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |-
15
15
  gmaps.js allows you to use the potential of Google Maps in a simple way.
@@ -27,7 +27,6 @@ files:
27
27
  - README.md
28
28
  - Rakefile
29
29
  - app/assets/javascripts/gmapsjs/gmapsjs.js
30
- - app/assets/javascripts/gmapsjs/index.js
31
30
  - gmapsjs.gemspec
32
31
  - lib/gmapsjs.rb
33
32
  - lib/gmapsjs/engine.rb
@@ -51,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
50
  version: '0'
52
51
  requirements: []
53
52
  rubyforge_project:
54
- rubygems_version: 2.2.2
53
+ rubygems_version: 2.4.5.1
55
54
  signing_key:
56
55
  specification_version: 4
57
56
  summary: ''
@@ -1 +0,0 @@
1
- //= require ./gmapsjs