map_monkey 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/map_monkey.rb +31 -1
  2. metadata +3 -3
data/lib/map_monkey.rb CHANGED
@@ -43,10 +43,40 @@ class Position
43
43
 
44
44
  lng = ""
45
45
 
46
- doc.elements.each('result/geometry/location/lng') do |ele|
46
+ doc.elements.each('GeocodeResponse/result/geometry/location/lng') do |ele|
47
47
  lng = ele.text
48
48
  end
49
49
 
50
50
  return lng
51
51
  end
52
+
53
+ def lat_lng(strCity, strStreet, strZip)
54
+ # Clean up the string
55
+ city = URI.encode(strCity)
56
+ street = URI.encode(strStreet)
57
+ zip = URI.encode(strZip)
58
+
59
+ # URL setup
60
+ url = "http://maps.googleapis.com/maps/api/geocode/xml?address=#{ street }#{ zip }#{ city }&sensor=false"
61
+
62
+ xml_data = Net::HTTP.get_response(URI.parse(url)).body
63
+
64
+ # xml-response
65
+ doc = REXML::Document.new(xml_data)
66
+
67
+ lat = ""
68
+ lng = ""
69
+
70
+ doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
71
+ lat = ele.text
72
+ end
73
+
74
+ doc.elements.each('GeocodeResponse/result/geometry/location/lng') do |ele|
75
+ lng = ele.text
76
+ end
77
+
78
+ lat_lng = [lat, lng]
79
+
80
+ return lat_lng
81
+ end
52
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: map_monkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-01-24 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: It returns your objects lat and long positions on a google map.
14
+ description: Returns lat and long positions on a google map.
15
15
  email:
16
16
  - ericintheloft@gmail.com
17
17
  executables: []
@@ -19,7 +19,7 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - lib/map_monkey.rb
22
- homepage: ''
22
+ homepage: https://github.com/eric-khoury/map_monkey
23
23
  licenses: []
24
24
  post_install_message:
25
25
  rdoc_options: []