package com.pattyjula.helloworld; import android.app.Activity; import android.os.Bundle; import com.esri.android.map.MapView; import com.esri.android.map.ags.ArcGISTiledMapServiceLayer; import com.esri.android.map.event.OnStatusChangedListener; import com.esri.android.map.ogc.KMLLayer; import com.esri.core.geometry.SpatialReference; public class HelloWorldActivity extends Activity { private String url = "http://dl.dropbox.com/u/2654618/kml/Wyoming.kml"; MapView mMapView; /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArcGISTiledMapServiceLayer tileLayer = new ArcGISTiledMapServiceLayer( "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); // Retrieve the map and initial extent from XML layout mMapView = (MapView)findViewById(R.id.map); mMapView.addLayer(tileLayer); mMapView.setOnStatusChangedListener(new OnStatusChangedListener() { public void onStatusChanged(Object object, STATUS status){ if (status == OnStatusChangedListener.STATUS.INITIALIZED) { SpatialReference sr = SpatialReference.create(102100); KMLLayer kmlLink = new KMLLayer(url, sr, true); kmlLink.refresh(); kmlLink.setVisible(true); mMapView.addLayer(kmlLink); } } }); } protected void onPause() { super.onPause(); mMapView.pause(); } protected void onResume() { super.onResume(); mMapView.unpause(); } }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.