WRLD Android Java API Samples
Samples demonstrating how to use the WRLD Android Java Api to display beautiful, interactive 3D maps on Android devices.
Building and running the samples
- Android Studio, together with the Android SDK and supporting libraries appropriate for your target platform.
- For running on Android devices, the library requires Android 4.0.3 (API level 15) or higher.
- Clone or downloaded snapshot of this repo.
- Sign up here for a free WRLD developer account.
- Navigate to API Keys and create API keys for the example apps in this repository:
- In the "New App" edit box enter "HelloWorld" and select "Create API Key".
- In the "New App" edit box enter "ApiSamples" and select "Create API Key".
- In the "New App" edit box enter "PoiExample" and select "Create API Key".
An API key is a string consisting of 32 alphanumeric characters. You will need to cut and paste each of the keys into a resource file in order to authenticate your apps. This is described in the 'Set your WRLD API key' step below.
Open Android Studio.
Select "Open an existing Android Studio project" and select the top level android-api-samples folder.
If Android Studio is missing supporting libraries or components, you may be prompted to install these. Otherwise, Android Studio will download prerequisites automatically from JCenter.
You should now see three modules in the project:
The helloworld example is a basic app displaying an WRLD map. It demonstates how to integrate WRLD maps into your existing Android application.
Build and run
To build it, select "helloworld" in the "Run/Debug configuration" toolbar and click "Make Project". If you have a debuggable Android device attached, or if you are running an emulator, you can debug or run the app with the standard Android Studio tools.
For a step-by-step instructions which show how to create a basic app from scratch, see our walkthrough documentation.
The apisamples app contains a collection of Activities, each illustrating an individual API feature.
Set your WRLD API key
Build and run
To build the examples, ensure "apisamples" is selected in the "Run/Debug configuration" toolbar, then "Run->Run 'apisamples'".
Set your WRLD API key
Create a Places Collection
- Go to Places Designer.
- To get you started, import the example Places provided in poi-examples.csv. Select 'Upload New Collection' and drag file poi-examples.csv into the upload box.
- You will now see a new Places Collection called "poi-examples" in the Places Designer sidebar. Click the pencil icon to open "Manage Place Collection" dialog.
- Click "+ Add An App". In the "Select App Key..." dropdown, select the "PoiExample" key that you created in 'Setup'.
- Click "Confirm Changes".
Build and run the app
To build the examples, ensure "poi-example" is selected in the Android Studio "Run/Debug configuration" toolbar, then "Run->Run 'poi-example'".
Types of Places
The example Places provided in poi-examples.csv demonstrate display using two types of Views.
- "Test POI 1" demonstrates a default View that displays each of the standard Place fields editable in Places Designer.
- "Test POI 2" demonstrates displaying custom HTML content. This Place has its 'user_data' -> 'custom_view' field populated with a web page url. You can read more about the 'user_data' fields in the WRLD POI API documentation.
Places Designer Tip
In Places Designer you can edit and preview a Place by selecting it to open the right-hand side panel.
See our API docs for detailed class documentation and other information.
Questions, comments, or problems? All feedback is welcome -- just create an issue.
WRLD Android SDK package
These samples make use of the WRLD Android SDK, available as a Maven package via Bintray.
The gradle scripts included in this samples repo mean that the package is downloaded automatically by Android Studio, via JCenter.
The source for the SDK is available at https://github.com/wrld3d/android-api
These examples are released under the Simplified BSD License. See the LICENSE.md file for details.