- Register your app in Google developer console: https://console.developers.google.com
You need to enable Google Maps Android API.
Then click on Credentials -> Create Credentials -> API Key -> Android Key.
You should get a key that looks like: AIzaSyCmFHamGE0O0BvxxxxxxxxXbTCSrjFVg-Q
- Copy the attached library and put it in the additional libraries folder. Add a reference to the GoogleMaps library.
- Add this to the manifest editor (replace the value with your key):
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase) AddApplicationText( <meta-data android:name="com.google.android.geo.API_KEY" android:value="xxxxxxxxxxxxxx"/> ) AddApplicationText( <uses-library android:name="org.apache.http.legacy" android:required="false" /> )
Don't add #AdditionalRes or #ExcludeClasses.
- Set minSdkVersion to 14 (Android 4).
- Add a MapFragment with the visual designer. It will appear under the CustomView menu. If you don't see it then make sure that the GoogleMaps library is selected.
You can change the properties from the designer.
Set the anchors to BOTH so the map will fill the activity:
Implement the Ready event to get a reference to the GoogleMap object.
Sub Process_Globals Private rp As RuntimePermissions End Sub Sub Globals Private gmap As GoogleMap Private MapFragment1 As MapFragment End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") Wait For MapFragment1_Ready gmap = MapFragment1.GetMap rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION) Wait For Activity_PermissionResult (Permission As String, Result As Boolean) If Result Then gmap.MyLocationEnabled = True Else Log("No permission!") End If End Sub
- v2.50 - Required dependencies were added to the library.
My Location Enabled property was removed from the designer as it needs to be set after the permission is granted.
- v2.02 EXTERNAL_STORAGE permission removed. It is no longer required.
GetOpenSourceLicenseInfo returns an empty string.
Fixes an issue with the ready event being lost if the activity is paused before the map is ready.
Note that you will need to update the package name and api key in the attached example.
8.4 KB Views: 501
19.4 KB Views: 564