B4A Library CompassView

The attached project wraps this Github project. The library files are in the /files folder of the attached B4A project. Copy them to your additional library folder. Also posting the Java code. You will also need to enable the Phone library in the B4A project. Move your device in different directions and see the compasses changing accordingly.






compassview
Author:
Johan Schoeman
Version: 1
  • CompassView
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • CompassBackgroundColor As Int [write only]
    • CompassDegrees As Float [write only]
    • CompassLineColor As Int [write only]
    • CompassMarkerColor As Int [write only]
    • CompassRangeDegrees As Float [write only]
    • CompassShowMarker As Boolean [write only]
    • CompassTextColor As Int [write only]
    • CompassTextSize As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • JavaCode.zip
    27.8 KB · Views: 750
  • b4aCompassView.zip
    31.1 KB · Views: 764

Johan Schoeman

Expert
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User
I am doing this purely for the fun of it @MarcoRome. You can use whatever you want (of what I have posted) in your apps. No need to donate anything. My "payment" is the satisfaction of seeing it "work"....
 

Harris

Expert
Licensed User
Longtime User
Just a note:

You do not need a device that supports phone sensors (PhoneOrientation - as my tablets do not).

I use it with GPS.
compass1.CompassDegrees = Location1.Bearing

This works perfectly well - setting the compass to show your current heading.

Thanks for this wrap.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…