Android Get Started
1. Copy SDK files to your project
a) Android Studio:
- Add following to build.gradle:
allprojects { repositories { mavenCentral() maven { url "http://repository-nutiteq.forge.cloudbees.com/release/" } maven { url "http://repository-nutiteq.forge.cloudbees.com/snapshot/" } } } dependencies { compile 'com.nutiteq:nutiteq-sdk:3.3.1@aar' }
b) Eclipse:
As minimum you need 3 files:
- nutiteq-maps-sdk.jar to project libs/ folder
- armeabi-v7a/libnutiteq_maps_sdk.so also to your project libs/ folder
- nutibright-v2a.zip style file to assets
The files are in SDK Downloads .
2. Make sure your AndroidManifest.xml defines INTERNET permission
<uses-permission android:name="android.permission.INTERNET"/>
3. Define your application layout
Define main layout as res/layout/main.xml, so it has com.nutiteq.ui.MapView element:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.nutiteq.ui.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>
4. Find MapView object
Now we will define MapView type of member in your main activity class, load layout and load the MapView from layout. The object itself was already created with layout creation, we just need to find it to have the object reference.
public class HelloMap3DActivity extends Activity { private MapView mapView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
5. Initialize and start map
Map object alone does not work right away, as it does not have default map source. Two steps are needed here as minimum to get it to work properly: (a) register license key, (b) define the first map layer, which will become base map. We use here vector map layer, configuration of it requires that you load and define style for it. You can use other layers also.
Replace YOUR_LICENSE_KEY with your license code. You have to be registered here (free plan is fine), and get the code from My apps page.
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // 1. The initial step: register your license. This must be done before using MapView! MapView.registerLicense("YOUR_LICENSE_KEY", getApplicationContext()); // Create map view mapView = (MapView) this.findViewById(R.id.mapView); // Create base layer. Use vector style from assets VectorTileLayer baseLayer = new NutiteqOnlineVectorTileLayer("nutibright-v2a.zip"); // Add layer to map mapView.getLayers().add(baseLayer); }
After this you can start the application on your phone and it should show map. Congratulations!
If you have issues, get our ready-made demo apps with many examples.