
Rhomobile Geo Controller
By: a guest on
Apr 24th, 2012 | syntax:
Ruby | size: 1.23 KB | hits: 48 | expires: Never
require 'rho/rhocontroller'
require 'helpers/browser_helper'
class GeoController < Rho::RhoController
include BrowserHelper
def geo_callback
if @params['known_position'].to_i != 0 && @params['status'] == 'ok'
$latitude = @params['latitude']
$longitude = @params['longitude']
end
end
# show error if timeout expired and GPS receiver didn't acquire position
if @params['available'].to_i == 0 || @params['status'] != 'ok'
@@gps_tries += 1
if @@gps_tries > 10
Alert.show_popup(
:message=>"Unable to obtain a GPS Signal.
Please make sure your GPS is activated. For iPhone, go to Settings ->
Location Services and makes sure it is 'On'. For Android, go to
Applications -> Settings -> Location & Security. Make sure that 'Use
GPS Satellites' is checked.",
:title=>"GPS Error",
:buttons => ["Ok"]
)
end
end
end
def get_my_location
if GeoLocation.known_position?
$latitude = GeoLocation.latitude
$longitude = GeoLocation.longitude
else
GeoLocation.set_notification( url_for(:controller => :Geo, :action => :geocall_back), "","")
end
end
end