Class: Ruflet::UI::Services::RufletServicesComponents::GeolocatorControl
- Inherits:
-
Control
- Object
- Control
- Ruflet::UI::Services::RufletServicesComponents::GeolocatorControl
- Defined in:
- lib/ruflet_ui/ruflet/ui/services/ruflet/geolocator_control.rb
Constant Summary collapse
- TYPE =
"geolocator".freeze
- WIRE =
"Geolocator".freeze
- KEYWORDS =
[:configuration, :data, :key, :on_error, :on_position_change].freeze
Constants inherited from Control
Control::HOST_EXPANDED_TYPES, Control::SCHEMA_METADATA_CACHE
Instance Attribute Summary
Attributes inherited from Control
#children, #id, #props, #runtime_page, #type, #wire_id
Instance Method Summary collapse
- #distance_between(start_latitude, start_longitude, end_latitude, end_longitude, timeout: 10, on_result: nil) ⇒ Object
- #get_current_position(configuration: nil, timeout: 10, on_result: nil) ⇒ Object
-
#initialize(id: nil, configuration: nil, data: nil, key: nil, on_error: nil, on_position_change: nil) ⇒ GeolocatorControl
constructor
A new instance of GeolocatorControl.
Methods inherited from Control
#attach_handler, #emit, generate_id, #has_handler?, #merge_props, #on, #to_patch
Constructor Details
#initialize(id: nil, configuration: nil, data: nil, key: nil, on_error: nil, on_position_change: nil) ⇒ GeolocatorControl
Returns a new instance of GeolocatorControl.
12 13 14 15 16 17 18 19 20 |
# File 'lib/ruflet_ui/ruflet/ui/services/ruflet/geolocator_control.rb', line 12 def initialize(id: nil, configuration: nil, data: nil, key: nil, on_error: nil, on_position_change: nil) props = {} props[:configuration] = configuration unless configuration.nil? props[:data] = data unless data.nil? props[:key] = key unless key.nil? props[:on_error] = on_error unless on_error.nil? props[:on_position_change] = on_position_change unless on_position_change.nil? super(type: TYPE, id: id, **props) end |
Instance Method Details
#distance_between(start_latitude, start_longitude, end_latitude, end_longitude, timeout: 10, on_result: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruflet_ui/ruflet/ui/services/ruflet/geolocator_control.rb', line 28 def distance_between(start_latitude, start_longitude, end_latitude, end_longitude, timeout: 10, on_result: nil) invoke_service( "distance_between", args: { "start_latitude" => start_latitude, "start_longitude" => start_longitude, "end_latitude" => end_latitude, "end_longitude" => end_longitude }, timeout: timeout, on_result: on_result ) end |
#get_current_position(configuration: nil, timeout: 10, on_result: nil) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/ruflet_ui/ruflet/ui/services/ruflet/geolocator_control.rb', line 42 def get_current_position(configuration: nil, timeout: 10, on_result: nil) # The public Ruflet/Flet API calls this value `configuration`, while # the Flutter service currently reads it from the `settings` invoke # argument. args = configuration.nil? ? nil : { "settings" => normalize_value(configuration) } invoke_service("get_current_position", args: args, timeout: timeout, on_result: on_result) end |