1

I created a kml using the kmllayer. When I set the map with a basemap and use the addLayer() method the kml is not shown. I can see the kml layer without a basemap. Can someone post sample code on using basemap with kml? am using ArcGISTiledMapServiceLayer as basemap

1

I added a KMLLayer to the HelloWorld sample that comes with the ArcGIS Android SDK.

public class HelloWorld extends Activity {
private String url = "http://code.google.com/apis/kml/documentation/us_states.kml";

MapView mMapView = null;
ArcGISTiledMapServiceLayer tileLayer;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Retrieve the map and initial extent from XML layout
    mMapView = (MapView)findViewById(R.id.map);
    /* create a @ArcGISTiledMapServiceLayer */
    tileLayer = new ArcGISTiledMapServiceLayer(
            "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");

    // Create a new KML Layer
    SpatialReference sr = SpatialReference.create(102100);
    KMLLayer kmlLayer = new KMLLayer(url, sr);

    // Add tiled layer to MapView
    mMapView.addLayer(tileLayer);

    // Add KML Layer to MapView;
    mMapView.addLayer(kmlLayer);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.