We will now create a page in our application that will give the current location of the device.
Follow these steps:
Create a folder called
GeoLocation
in theapp
folder.Create a file called
controller.erb
and write the following code: require 'rho/rhocontroller' class GeoLocationController < Rho::RhoController def index set_geoview_notification( url_for(:action => :geo_viewcallback), "", 2) if System::get_property('platform') == 'Blackberry' render :back => '/app' end def geo_viewcallback WebView.refresh if @params['known_position'].to_i != 0 && @params['status'] =='ok' end def showmap region = [@params['latitude'], @params['longitude'], 0.2, 0.2] map_params = { :provider => @params['provider'], :settings => {:map_type => "roadmap", :region => region, :zoom_enabled => true, :scroll_enabled => true, :shows_user_location => true}, ...