gmapsjs 0.2.3 → 0.2.4

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.
@@ -616,10 +616,6 @@ var GMaps = (function(global) {
616
616
  this.polygons.push(polygon);
617
617
 
618
618
  return polygon;
619
-
620
- function arrayToLatLng(coords) {
621
- return new google.maps.LatLng(coords[0], coords[1]);
622
- }
623
619
  };
624
620
 
625
621
  this.getFromFusionTables = function(options) {
@@ -738,6 +734,48 @@ var GMaps = (function(global) {
738
734
  });
739
735
  };
740
736
 
737
+ this.getElevations = function(options) {
738
+ options = extend_object({
739
+ locations: [],
740
+ path : false,
741
+ samples : 256
742
+ }, options);
743
+
744
+ if(options.locations.length > 0) {
745
+ if(options.locations[0].length > 0) {
746
+ options.locations = array_map(options.locations, arrayToLatLng);
747
+ }
748
+ }
749
+
750
+ var callback = options.callback;
751
+ delete options.callback;
752
+
753
+ var service = new google.maps.ElevationService();
754
+
755
+ //location request
756
+ if (!options.path) {
757
+ delete options.path;
758
+ delete options.samples;
759
+ service.getElevationForLocations(options, function(result, status){
760
+ if (callback && typeof(callback) === "function") {
761
+ callback(result, status);
762
+ }
763
+ });
764
+ //path request
765
+ } else {
766
+ var pathRequest = {
767
+ path : options.locations,
768
+ samples : options.samples
769
+ };
770
+
771
+ service.getElevationAlongPath(pathRequest, function(result, status){
772
+ if (callback && typeof(callback) === "function") {
773
+ callback(result, status);
774
+ }
775
+ });
776
+ }
777
+ };
778
+
741
779
  this.removePolylines = function(){
742
780
  var index;
743
781
  for(index in this.polylines){
@@ -1176,6 +1214,10 @@ var GMaps = (function(global) {
1176
1214
  return GMaps;
1177
1215
  }(this));
1178
1216
 
1217
+ var arrayToLatLng = function(coords) {
1218
+ return new google.maps.LatLng(coords[0], coords[1]);
1219
+ }
1220
+
1179
1221
  var extend_object = function(obj, new_obj) {
1180
1222
  if(obj === new_obj) return obj;
1181
1223
 
@@ -1,3 +1,3 @@
1
1
  module GmapsJS
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
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.2.3
4
+ version: 0.2.4
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-07-18 00:00:00.000000000Z
13
+ date: 2012-07-26 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.