-
Notifications
You must be signed in to change notification settings - Fork 32
Home
This project is designed for rapidly prototyping native Android mapping applications. It requires the use of the ArcGIS Runtime SDK for Android. It significantly simplifies some of the most common coding patterns down to just a one or a couple lines of code. For example, here's the code to add a map, center it and zoom in:
_esriQuickStartLib = new EsriQuickStart(this,R.id.map);
_esriQuickStartLib.addLayer(MapType.STREETS, 39.87, -104.67, 5, true);
Included in this repo are the QuickStart Android library project and the QuickStart sample application that shows how to use the library.
QuickStart API Documentation.
Follow the steps on the ArcGIS Resource Center to install the ArcGIS Runtime SDK for Android and set up your Eclipse environment. Note: you will need an Esri account to download the runtime. Learn more here.
Then follow the steps in the tutorial to build a Hello World Map and make sure it works on your development environment. Run the application on an emulator or phone and you should see the map.
-
Go to Github and either clone or download the code from the quickstart-map-android repo.
-
If you are just using the stand-alone library, in Eclipse right click on your project and under Properties > Java Build Path > Libraries > Add JARs. If you are using the entire library project, then right click on your project and under Properties > Android > Library be sure to “add” the EsriQuickStart library project.
-
Under Properties > Java Build Path > Order and Export select the check box for esriquickstart.jar. Then run Project > Clean.
-
Comment out all the MapView code and replace it with the QuickStart code:
public class EsriQuickStartTemplateActivity extends Activity { EsriQuickStart _esriQuickStartLib = null; //MapView mapView = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //mapView = new MapView(this); _esriQuickStartLib = new EsriQuickStart(this,R.id.map); _esriQuickStartLib.addLayer(MapType.STREETS, null, null, null,true); } @Override protected void onDestroy() { super.onDestroy(); } @Override protected void onPause() { _esriQuickStartLib.pause(); //mapView.pause(); super.onPause(); } @Override protected void onResume() { super.onResume(); _esriQuickStartLib.unpause(); //mapView.unpause(); } }
-
Add the android:configChanges property to the AndroidManifest.xml file. This will prevent the onCreate method from being called every time the phone orientation changes:
<activity android:name=".HelloWorldActivity" android:label="@string/app_name" android:configChanges="orientation">
-
Run the app in the emulator or on a phone and you should see the map.