地图定位程序代码

ExampleInstrumentedTest文件:




package esrichina.hymn.setmapinitiallocation;


import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;


import org.junit.Test;
import org.junit.runner.RunWith;


import static org.junit.Assert.*;


/**
 * Instrumentation test, which will execute on an Android device.
 *
 * @see Testing documentation
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() throws Exception {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getTargetContext();


        assertEquals("esrichina.hymn.setmapinitiallocation", appContext.getPackageName());
    }
}




MainActivity文件:




package esrichina.hymn.setmapinitiallocation;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.MapView;
public class MainActivity extends AppCompatActivity {
    private MapView mMapView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mMapView = (MapView) findViewById(R.id.mapView);
        ArcGISMap map = new ArcGISMap
                (Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 16);
        mMapView.setMap(map);
    }
}






activity_main文件:







    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="esrichina.hymn.setmapinitiallocation.MainActivity">
            android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
   








colors文件:






    #3F51B5
    #303F9F
    #FF4081







strings文件:







    Set Map Initial Location







styles文件:







   
   


下面附有该程序项目源码,已经运行过,可以使用。

你可能感兴趣的:(代码博)