gmapsjs 0.2.4.1 → 0.2.13
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.
- data/app/assets/javascripts/gmapsjs/gmapsjs.js +290 -48
- data/lib/gmapsjs/version.rb +1 -1
- metadata +3 -3
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* GMaps.js
|
2
|
+
* GMaps.js v0.2.13
|
3
3
|
* http://hpneo.github.com/gmaps/
|
4
4
|
*
|
5
5
|
* Copyright 2012, Gustavo Leon
|
@@ -29,12 +29,13 @@ if(window.google && window.google.maps){
|
|
29
29
|
if(typeof(options.div)=='string'){
|
30
30
|
this.div = getElementById(options.div, options.context);
|
31
31
|
}else{this.div = options.div;};
|
32
|
-
this.div.style.width = this.div.
|
33
|
-
this.div.style.height = this.div.
|
32
|
+
this.div.style.width = options.width || this.div.scrollWidth || this.div.offsetWidth;
|
33
|
+
this.div.style.height = options.height || this.div.scrollHeight || this.div.offsetHeight;
|
34
34
|
|
35
35
|
this.controls = [];
|
36
36
|
this.overlays = [];
|
37
|
-
this.layers = [];
|
37
|
+
this.layers = []; // array with kml and ft layers, can be as many
|
38
|
+
this.singleLayers = {}; // object with the other layers, only one per layer
|
38
39
|
this.markers = [];
|
39
40
|
this.polylines = [];
|
40
41
|
this.routes = [];
|
@@ -76,8 +77,6 @@ if(window.google && window.google.maps){
|
|
76
77
|
streetViewControl = options.streetViewControl || true,
|
77
78
|
overviewMapControl = overviewMapControl || true;
|
78
79
|
|
79
|
-
|
80
|
-
|
81
80
|
var map_base_options = {
|
82
81
|
zoom: this.zoom,
|
83
82
|
center: map_center,
|
@@ -109,7 +108,9 @@ if(window.google && window.google.maps){
|
|
109
108
|
option.title + '</a></li>';
|
110
109
|
}
|
111
110
|
}
|
111
|
+
|
112
112
|
if(!getElementById('gmaps_context_menu')) return;
|
113
|
+
|
113
114
|
var context_menu_element = getElementById('gmaps_context_menu');
|
114
115
|
context_menu_element.innerHTML = html;
|
115
116
|
|
@@ -206,6 +207,9 @@ if(window.google && window.google.maps){
|
|
206
207
|
for (var ev = 0; ev < events_that_hide_context_menu.length; ev++) {
|
207
208
|
(function(object, name) {
|
208
209
|
google.maps.event.addListener(object, name, function(e){
|
210
|
+
if(e == undefined)
|
211
|
+
e = this;
|
212
|
+
|
209
213
|
if (options[name])
|
210
214
|
options[name].apply(this, [e]);
|
211
215
|
|
@@ -217,6 +221,9 @@ if(window.google && window.google.maps){
|
|
217
221
|
for (var ev = 0; ev < events_that_doesnt_hide_context_menu.length; ev++) {
|
218
222
|
(function(object, name) {
|
219
223
|
google.maps.event.addListener(object, name, function(e){
|
224
|
+
if(e == undefined)
|
225
|
+
e = this;
|
226
|
+
|
220
227
|
if (options[name])
|
221
228
|
options[name].apply(this, [e]);
|
222
229
|
});
|
@@ -265,30 +272,36 @@ if(window.google && window.google.maps){
|
|
265
272
|
}
|
266
273
|
};
|
267
274
|
|
268
|
-
this.getCenter = function() {
|
269
|
-
return this.map.getCenter();
|
270
|
-
};
|
271
|
-
|
272
275
|
this.getDiv = function() {
|
273
276
|
return this.div;
|
274
277
|
};
|
275
278
|
|
276
|
-
this.setZoom = function(value) {
|
277
|
-
this.map.setZoom(value);
|
278
|
-
};
|
279
|
-
|
280
|
-
this.getZoom = function() {
|
281
|
-
return this.map.getZoom();
|
282
|
-
};
|
283
|
-
|
284
279
|
this.zoomIn = function(value) {
|
285
|
-
this.
|
280
|
+
this.zoom = this.map.getZoom() + value;
|
281
|
+
this.map.setZoom(this.zoom);
|
286
282
|
};
|
287
283
|
|
288
284
|
this.zoomOut = function(value) {
|
289
|
-
this.
|
285
|
+
this.zoom = this.map.getZoom() - value;
|
286
|
+
this.map.setZoom(this.zoom);
|
290
287
|
};
|
291
288
|
|
289
|
+
var native_methods = [];
|
290
|
+
|
291
|
+
for(var method in this.map){
|
292
|
+
if(typeof(this.map[method]) == 'function' && !this[method]){
|
293
|
+
native_methods.push(method);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
for(var i=0; i < native_methods.length; i++){
|
298
|
+
(function(gmaps, scope, method_name) {
|
299
|
+
gmaps[method_name] = function(){
|
300
|
+
return scope[method_name].apply(scope, arguments);
|
301
|
+
};
|
302
|
+
})(this, this.map, native_methods[i]);
|
303
|
+
}
|
304
|
+
|
292
305
|
this.createControl = function(options) {
|
293
306
|
var control = doc.createElement('div');
|
294
307
|
|
@@ -330,7 +343,7 @@ if(window.google && window.google.maps){
|
|
330
343
|
|
331
344
|
// Markers
|
332
345
|
this.createMarker = function(options) {
|
333
|
-
if ((options.lat && options.lng) || options.position) {
|
346
|
+
if ((options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) || options.position) {
|
334
347
|
var self = this;
|
335
348
|
var details = options.details;
|
336
349
|
var fences = options.fences;
|
@@ -367,7 +380,9 @@ if(window.google && window.google.maps){
|
|
367
380
|
}
|
368
381
|
}
|
369
382
|
|
370
|
-
var marker_events = ['
|
383
|
+
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'];
|
384
|
+
|
385
|
+
var marker_events_with_mouse = ['dblclick', 'drag', 'dragend', 'dragstart', 'mousedown', 'mouseout', 'mouseover', 'mouseup'];
|
371
386
|
|
372
387
|
for (var ev = 0; ev < marker_events.length; ev++) {
|
373
388
|
(function(object, name) {
|
@@ -378,6 +393,18 @@ if(window.google && window.google.maps){
|
|
378
393
|
})(marker, marker_events[ev]);
|
379
394
|
}
|
380
395
|
|
396
|
+
for (var ev = 0; ev < marker_events.length; ev++) {
|
397
|
+
(function(object, name) {
|
398
|
+
google.maps.event.addListener(object, name, function(me){
|
399
|
+
if(!me.pixel){
|
400
|
+
me.pixel = this.map.getProjection().fromLatLngToPoint(me.latLng)
|
401
|
+
}
|
402
|
+
if (options[name])
|
403
|
+
options[name].apply(this, [me]);
|
404
|
+
});
|
405
|
+
})(marker, marker_events_with_mouse[ev]);
|
406
|
+
}
|
407
|
+
|
381
408
|
google.maps.event.addListener(marker, 'click', function() {
|
382
409
|
this.details = details;
|
383
410
|
|
@@ -393,9 +420,6 @@ if(window.google && window.google.maps){
|
|
393
420
|
|
394
421
|
if (options.dragend || marker.fences) {
|
395
422
|
google.maps.event.addListener(marker, 'dragend', function() {
|
396
|
-
if (options.dragend) {
|
397
|
-
options.dragend.apply(this, [this]);
|
398
|
-
}
|
399
423
|
if (marker.fences) {
|
400
424
|
self.checkMarkerGeofence(marker, function(m, f) {
|
401
425
|
outside(m, f);
|
@@ -412,7 +436,7 @@ if(window.google && window.google.maps){
|
|
412
436
|
};
|
413
437
|
|
414
438
|
this.addMarker = function(options) {
|
415
|
-
if ((options.lat && options.lng) || options.position) {
|
439
|
+
if ((options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) || options.position) {
|
416
440
|
var marker = this.createMarker(options);
|
417
441
|
marker.setMap(this.map);
|
418
442
|
this.markers.push(marker);
|
@@ -439,11 +463,22 @@ if(window.google && window.google.maps){
|
|
439
463
|
}
|
440
464
|
};
|
441
465
|
|
442
|
-
this.removeMarkers = function() {
|
443
|
-
|
444
|
-
|
466
|
+
this.removeMarkers = function(collection) {
|
467
|
+
var collection = (collection || this.markers);
|
468
|
+
|
469
|
+
for(var i=0;i < this.markers.length; i++){
|
470
|
+
if(this.markers[i] === collection[i])
|
471
|
+
this.markers[i].setMap(null);
|
445
472
|
}
|
446
|
-
|
473
|
+
|
474
|
+
var new_markers = [];
|
475
|
+
|
476
|
+
for(var i=0;i < this.markers.length; i++){
|
477
|
+
if(this.markers[i].getMap() != null)
|
478
|
+
new_markers.push(this.markers[i]);
|
479
|
+
}
|
480
|
+
|
481
|
+
this.markers = new_markers;
|
447
482
|
};
|
448
483
|
|
449
484
|
// Overlays
|
@@ -451,6 +486,11 @@ if(window.google && window.google.maps){
|
|
451
486
|
var overlay = new google.maps.OverlayView();
|
452
487
|
overlay.setMap(self.map);
|
453
488
|
|
489
|
+
var auto_show = true;
|
490
|
+
|
491
|
+
if(options.auto_show != null)
|
492
|
+
auto_show = options.auto_show;
|
493
|
+
|
454
494
|
overlay.onAdd = function() {
|
455
495
|
var div = doc.createElement('div');
|
456
496
|
div.style.borderStyle = "none";
|
@@ -459,7 +499,7 @@ if(window.google && window.google.maps){
|
|
459
499
|
div.style.zIndex = 100;
|
460
500
|
div.innerHTML = options.content;
|
461
501
|
|
462
|
-
|
502
|
+
overlay.div = div;
|
463
503
|
|
464
504
|
var panes = this.getPanes();
|
465
505
|
if (!options.layer) {
|
@@ -467,6 +507,24 @@ if(window.google && window.google.maps){
|
|
467
507
|
}
|
468
508
|
var overlayLayer = panes[options.layer];
|
469
509
|
overlayLayer.appendChild(div);
|
510
|
+
|
511
|
+
var stop_overlay_events = ['contextmenu', 'DOMMouseScroll', 'dblclick', 'mousedown'];
|
512
|
+
|
513
|
+
for (var ev = 0; ev < stop_overlay_events.length; ev++) {
|
514
|
+
(function(object, name) {
|
515
|
+
google.maps.event.addDomListener(object, name, function(e){
|
516
|
+
if(navigator.userAgent.toLowerCase().indexOf('msie') != -1 && document.all) {
|
517
|
+
e.cancelBubble = true;
|
518
|
+
e.returnValue = false;
|
519
|
+
}
|
520
|
+
else {
|
521
|
+
e.stopPropagation();
|
522
|
+
}
|
523
|
+
});
|
524
|
+
})(div, stop_overlay_events[ev]);
|
525
|
+
}
|
526
|
+
|
527
|
+
google.maps.event.trigger(this, 'ready');
|
470
528
|
};
|
471
529
|
|
472
530
|
overlay.draw = function() {
|
@@ -476,7 +534,7 @@ if(window.google && window.google.maps){
|
|
476
534
|
options.horizontalOffset = options.horizontalOffset || 0;
|
477
535
|
options.verticalOffset = options.verticalOffset || 0;
|
478
536
|
|
479
|
-
var div =
|
537
|
+
var div = overlay.div;
|
480
538
|
var content = div.children[0];
|
481
539
|
|
482
540
|
var content_height = content.clientHeight;
|
@@ -507,12 +565,26 @@ if(window.google && window.google.maps){
|
|
507
565
|
div.style.left = (pixel.x + options.horizontalOffset) + 'px';
|
508
566
|
break;
|
509
567
|
}
|
568
|
+
|
569
|
+
div.style.display = auto_show ? 'block' : 'none';
|
570
|
+
|
571
|
+
if(!auto_show){
|
572
|
+
options.show.apply(this, [div]);
|
573
|
+
}
|
510
574
|
};
|
511
575
|
|
512
576
|
overlay.onRemove = function() {
|
513
|
-
|
514
|
-
|
577
|
+
var div = overlay.div;
|
578
|
+
|
579
|
+
if(options.remove){
|
580
|
+
options.remove.apply(this, [div]);
|
581
|
+
}
|
582
|
+
else{
|
583
|
+
overlay.div.parentNode.removeChild(overlay.div);
|
584
|
+
overlay.div = null;
|
585
|
+
}
|
515
586
|
};
|
587
|
+
|
516
588
|
self.overlays.push(overlay);
|
517
589
|
return overlay;
|
518
590
|
};
|
@@ -528,6 +600,13 @@ if(window.google && window.google.maps){
|
|
528
600
|
self.overlays = [];
|
529
601
|
};
|
530
602
|
|
603
|
+
this.removePolylines = function() {
|
604
|
+
for (var i=0, item; item=self.polylines[i]; i++){
|
605
|
+
item.setMap(null);
|
606
|
+
}
|
607
|
+
self.polylines = [];
|
608
|
+
};
|
609
|
+
|
531
610
|
this.drawPolyline = function(options) {
|
532
611
|
var path = [];
|
533
612
|
var points = options.path;
|
@@ -548,7 +627,8 @@ if(window.google && window.google.maps){
|
|
548
627
|
path: path,
|
549
628
|
strokeColor: options.strokeColor,
|
550
629
|
strokeOpacity: options.strokeOpacity,
|
551
|
-
strokeWeight: options.strokeWeight
|
630
|
+
strokeWeight: options.strokeWeight,
|
631
|
+
geodesic: options.geodesic
|
552
632
|
});
|
553
633
|
|
554
634
|
var polyline_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
|
@@ -588,6 +668,8 @@ if(window.google && window.google.maps){
|
|
588
668
|
})(polygon, polygon_events[ev]);
|
589
669
|
}
|
590
670
|
|
671
|
+
this.polygons.push(polygon);
|
672
|
+
|
591
673
|
return polygon;
|
592
674
|
};
|
593
675
|
|
@@ -616,6 +698,8 @@ if(window.google && window.google.maps){
|
|
616
698
|
})(polygon, polygon_events[ev]);
|
617
699
|
}
|
618
700
|
|
701
|
+
this.polygons.push(polygon);
|
702
|
+
|
619
703
|
return polygon;
|
620
704
|
};
|
621
705
|
|
@@ -648,6 +732,15 @@ if(window.google && window.google.maps){
|
|
648
732
|
return polygon;
|
649
733
|
};
|
650
734
|
|
735
|
+
this.removePolygon = this.removeOverlay;
|
736
|
+
|
737
|
+
this.removePolygons = function() {
|
738
|
+
for (var i=0, item; item=self.polygons[i]; i++){
|
739
|
+
item.setMap(null);
|
740
|
+
}
|
741
|
+
self.polygons = [];
|
742
|
+
};
|
743
|
+
|
651
744
|
this.getFromFusionTables = function(options) {
|
652
745
|
var events = options.events;
|
653
746
|
|
@@ -715,6 +808,9 @@ if(window.google && window.google.maps){
|
|
715
808
|
case 'bicycling':
|
716
809
|
travelMode = google.maps.TravelMode.BICYCLING;
|
717
810
|
break;
|
811
|
+
case 'transit':
|
812
|
+
travelMode = google.maps.TravelMode.TRANSIT;
|
813
|
+
break;
|
718
814
|
case 'driving':
|
719
815
|
travelMode = google.maps.TravelMode.DRIVING;
|
720
816
|
break;
|
@@ -764,6 +860,10 @@ if(window.google && window.google.maps){
|
|
764
860
|
});
|
765
861
|
};
|
766
862
|
|
863
|
+
this.removeRoutes = function() {
|
864
|
+
this.routes = [];
|
865
|
+
};
|
866
|
+
|
767
867
|
this.getElevations = function(options) {
|
768
868
|
options = extend_object({
|
769
869
|
locations: [],
|
@@ -806,14 +906,6 @@ if(window.google && window.google.maps){
|
|
806
906
|
}
|
807
907
|
};
|
808
908
|
|
809
|
-
this.removePolylines = function(){
|
810
|
-
var index;
|
811
|
-
for(index in this.polylines){
|
812
|
-
this.polylines[index].setMap(null);
|
813
|
-
}
|
814
|
-
this.polylines = [];
|
815
|
-
}
|
816
|
-
|
817
909
|
// Alias for the method "drawRoute"
|
818
910
|
this.cleanRoute = this.removePolylines;
|
819
911
|
|
@@ -848,16 +940,27 @@ if(window.google && window.google.maps){
|
|
848
940
|
travelMode: options.travelMode,
|
849
941
|
waypoints : options.waypoints,
|
850
942
|
callback: function(e) {
|
943
|
+
//start callback
|
944
|
+
if (e.length > 0 && options.start) {
|
945
|
+
options.start(e[e.length - 1]);
|
946
|
+
}
|
947
|
+
|
948
|
+
//step callback
|
851
949
|
if (e.length > 0 && options.step) {
|
852
950
|
var route = e[e.length - 1];
|
853
951
|
if (route.legs.length > 0) {
|
854
952
|
var steps = route.legs[0].steps;
|
855
953
|
for (var i=0, step; step=steps[i]; i++) {
|
856
954
|
step.step_number = i;
|
857
|
-
options.step(step);
|
955
|
+
options.step(step, (route.legs[0].steps.length - 1));
|
858
956
|
}
|
859
957
|
}
|
860
958
|
}
|
959
|
+
|
960
|
+
//end callback
|
961
|
+
if (e.length > 0 && options.end) {
|
962
|
+
options.end(e[e.length - 1]);
|
963
|
+
}
|
861
964
|
}
|
862
965
|
});
|
863
966
|
}
|
@@ -878,7 +981,14 @@ if(window.google && window.google.maps){
|
|
878
981
|
origin: options.origin,
|
879
982
|
destination: options.destination,
|
880
983
|
travelMode: options.travelMode,
|
984
|
+
waypoints : options.waypoints,
|
881
985
|
callback: function(e) {
|
986
|
+
//start callback
|
987
|
+
if (e.length > 0 && options.start) {
|
988
|
+
options.start(e[e.length - 1]);
|
989
|
+
}
|
990
|
+
|
991
|
+
//step callback
|
882
992
|
if (e.length > 0 && options.step) {
|
883
993
|
var route = e[e.length - 1];
|
884
994
|
if (route.legs.length > 0) {
|
@@ -891,10 +1001,15 @@ if(window.google && window.google.maps){
|
|
891
1001
|
strokeOpacity: options.strokeOpacity,
|
892
1002
|
strokeWeight: options.strokeWeight
|
893
1003
|
});
|
894
|
-
options.step(step);
|
1004
|
+
options.step(step, (route.legs[0].steps.length - 1));
|
895
1005
|
}
|
896
1006
|
}
|
897
1007
|
}
|
1008
|
+
|
1009
|
+
//end callback
|
1010
|
+
if (e.length > 0 && options.end) {
|
1011
|
+
options.end(e[e.length - 1]);
|
1012
|
+
}
|
898
1013
|
}
|
899
1014
|
});
|
900
1015
|
}
|
@@ -930,6 +1045,124 @@ if(window.google && window.google.maps){
|
|
930
1045
|
}
|
931
1046
|
}
|
932
1047
|
};
|
1048
|
+
|
1049
|
+
//add layers to the maps
|
1050
|
+
this.addLayer = function(layerName, options) {
|
1051
|
+
//var default_layers = ['weather', 'clouds', 'traffic', 'transit', 'bicycling', 'panoramio', 'places'];
|
1052
|
+
options = options || {};
|
1053
|
+
var layer;
|
1054
|
+
|
1055
|
+
switch(layerName) {
|
1056
|
+
case 'weather': this.singleLayers.weather = layer = new google.maps.weather.WeatherLayer();
|
1057
|
+
break;
|
1058
|
+
case 'clouds': this.singleLayers.clouds = layer = new google.maps.weather.CloudLayer();
|
1059
|
+
break;
|
1060
|
+
case 'traffic': this.singleLayers.traffic = layer = new google.maps.TrafficLayer();
|
1061
|
+
break;
|
1062
|
+
case 'transit': this.singleLayers.transit = layer = new google.maps.TransitLayer();
|
1063
|
+
break;
|
1064
|
+
case 'bicycling': this.singleLayers.bicycling = layer = new google.maps.BicyclingLayer();
|
1065
|
+
break;
|
1066
|
+
case 'panoramio':
|
1067
|
+
this.singleLayers.panoramio = layer = new google.maps.panoramio.PanoramioLayer();
|
1068
|
+
layer.setTag(options.filter);
|
1069
|
+
delete options.filter;
|
1070
|
+
|
1071
|
+
//click event
|
1072
|
+
if(options.click) {
|
1073
|
+
google.maps.event.addListener(layer, 'click', function(event) {
|
1074
|
+
options.click(event);
|
1075
|
+
delete options.click;
|
1076
|
+
});
|
1077
|
+
}
|
1078
|
+
break;
|
1079
|
+
case 'places':
|
1080
|
+
this.singleLayers.places = layer = new google.maps.places.PlacesService(this.map);
|
1081
|
+
|
1082
|
+
//search and nearbySearch callback, Both are the same
|
1083
|
+
if(options.search || options.nearbySearch) {
|
1084
|
+
var placeSearchRequest = {
|
1085
|
+
bounds : options.bounds || null,
|
1086
|
+
keyword : options.keyword || null,
|
1087
|
+
location : options.location || null,
|
1088
|
+
name : options.name || null,
|
1089
|
+
radius : options.radius || null,
|
1090
|
+
rankBy : options.rankBy || null,
|
1091
|
+
types : options.types || null
|
1092
|
+
};
|
1093
|
+
|
1094
|
+
if(options.search) {
|
1095
|
+
layer.search(placeSearchRequest, options.search);
|
1096
|
+
}
|
1097
|
+
|
1098
|
+
if(options.nearbySearch) {
|
1099
|
+
layer.nearbySearch(placeSearchRequest, options.nearbySearch);
|
1100
|
+
}
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
//textSearch callback
|
1104
|
+
if(options.textSearch) {
|
1105
|
+
var textSearchRequest = {
|
1106
|
+
bounds : options.bounds || null,
|
1107
|
+
location : options.location || null,
|
1108
|
+
query : options.query || null,
|
1109
|
+
radius : options.radius || null
|
1110
|
+
};
|
1111
|
+
|
1112
|
+
layer.textSearch(textSearchRequest, options.textSearch);
|
1113
|
+
}
|
1114
|
+
break;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
if(layer !== undefined) {
|
1118
|
+
if(typeof layer.setOptions == 'function') {
|
1119
|
+
layer.setOptions(options);
|
1120
|
+
}
|
1121
|
+
if(typeof layer.setMap == 'function') {
|
1122
|
+
layer.setMap(this.map);
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
return layer;
|
1126
|
+
}
|
1127
|
+
};
|
1128
|
+
|
1129
|
+
//remove layers
|
1130
|
+
this.removeLayer = function(layerName) {
|
1131
|
+
if(this.singleLayers[layerName] !== undefined) {
|
1132
|
+
this.singleLayers[layerName].setMap(null);
|
1133
|
+
delete this.singleLayers[layerName];
|
1134
|
+
}
|
1135
|
+
};
|
1136
|
+
|
1137
|
+
this.toImage = function(options) {
|
1138
|
+
var options = options || {};
|
1139
|
+
var static_map_options = {};
|
1140
|
+
static_map_options['size'] = options['size'] || [this.div.clientWidth, this.div.clientHeight];
|
1141
|
+
static_map_options['lat'] = this.getCenter().lat();
|
1142
|
+
static_map_options['lng'] = this.getCenter().lng();
|
1143
|
+
|
1144
|
+
if(this.markers.length > 0) {
|
1145
|
+
static_map_options['markers'] = [];
|
1146
|
+
for(var i=0; i < this.markers.length; i++) {
|
1147
|
+
static_map_options['markers'].push({
|
1148
|
+
lat: this.markers[i].getPosition().lat(),
|
1149
|
+
lng: this.markers[i].getPosition().lng()
|
1150
|
+
});
|
1151
|
+
}
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
if(this.polylines.length > 0) {
|
1155
|
+
var polyline = this.polylines[0];
|
1156
|
+
static_map_options['polyline'] = {};
|
1157
|
+
static_map_options['polyline']['path'] = google.maps.geometry.encoding.encodePath(polyline.getPath());
|
1158
|
+
static_map_options['polyline']['strokeColor'] = polyline.strokeColor
|
1159
|
+
static_map_options['polyline']['strokeOpacity'] = polyline.strokeOpacity
|
1160
|
+
static_map_options['polyline']['strokeWeight'] = polyline.strokeWeight
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
return GMaps.staticMapURL(static_map_options);
|
1164
|
+
};
|
1165
|
+
|
933
1166
|
};
|
934
1167
|
|
935
1168
|
GMaps.Route = function(options) {
|
@@ -998,7 +1231,7 @@ if(window.google && window.google.maps){
|
|
998
1231
|
GMaps.geocode = function(options) {
|
999
1232
|
this.geocoder = new google.maps.Geocoder();
|
1000
1233
|
var callback = options.callback;
|
1001
|
-
if (options.lat && options.lng) {
|
1234
|
+
if (options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) {
|
1002
1235
|
options.latLng = new google.maps.LatLng(options.lat, options.lng);
|
1003
1236
|
}
|
1004
1237
|
|
@@ -1246,7 +1479,7 @@ if(window.google && window.google.maps){
|
|
1246
1479
|
|
1247
1480
|
var arrayToLatLng = function(coords) {
|
1248
1481
|
return new google.maps.LatLng(coords[0], coords[1]);
|
1249
|
-
}
|
1482
|
+
};
|
1250
1483
|
|
1251
1484
|
var extend_object = function(obj, new_obj) {
|
1252
1485
|
if(obj === new_obj) return obj;
|
@@ -1274,4 +1507,13 @@ if(window.google && window.google.maps){
|
|
1274
1507
|
}
|
1275
1508
|
}
|
1276
1509
|
|
1277
|
-
}
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
/*Extension: Styled map*/
|
1513
|
+
GMaps.prototype.addStyle = function(options){
|
1514
|
+
var styledMapType = new google.maps.StyledMapType(options.styles, options.styledMapName);
|
1515
|
+
this.map.mapTypes.set(options.mapTypeId, styledMapType);
|
1516
|
+
};
|
1517
|
+
GMaps.prototype.setStyle = function(mapTypeId){
|
1518
|
+
this.map.setMapTypeId(mapTypeId);
|
1519
|
+
};
|
data/lib/gmapsjs/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-24 00:00:00.000000000Z
|
14
14
|
dependencies: []
|
15
15
|
description: ! 'gmaps.js allows you to use the potential of Google Maps in a simple
|
16
16
|
way.
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
56
|
rubyforge_project:
|
57
|
-
rubygems_version: 1.8.
|
57
|
+
rubygems_version: 1.8.17
|
58
58
|
signing_key:
|
59
59
|
specification_version: 3
|
60
60
|
summary: ''
|