class MapmyindiaRuby::Base
Attributes
key[R]
Public Class Methods
new(key, url='https://api.mapmyindia.com/v3')
click to toggle source
# File lib/mapmyindia_ruby/base.rb, line 12 def initialize(key, url='https://api.mapmyindia.com/v3') self.class.base_uri url @key = key end
Public Instance Methods
distance(params)
click to toggle source
# File lib/mapmyindia_ruby/base.rb, line 36 def distance(params) params.merge!({ :lic_key => @key, :fun => 'star_dists' }) response = self.class.get("",{ :query => params }) JSON.parse(response.body) end
geocoding(query_string)
click to toggle source
# File lib/mapmyindia_ruby/base.rb, line 17 def geocoding(query_string) params = { :lic_key => @key, :q => query_string, :fun => 'geocode' } response = self.class.get("",{ :query => params }) GeoAddr.build(response) end
map_tile_image(params, path)
click to toggle source
# File lib/mapmyindia_ruby/base.rb, line 44 def map_tile_image(params, path) params.merge!({ :lic_key => @key, :fun => 'still_map' }) response = self.class.get("",{ :query => params }) File.open(path,'wb'){|f| f.write(response.body)} end
reverse_geocoding(lat,lng)
click to toggle source
# File lib/mapmyindia_ruby/base.rb, line 26 def reverse_geocoding(lat,lng) params = { :lic_key => @key, :lat => lat, :lng => lng, :fun => 'rev_geocode' } response = self.class.get("",{ :query => params }) GeoAddr.build(response) end