public class HelloWorld extends Activity { MapView map = null; /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Retrieve the map and initial extent from XML layout map = (MapView)findViewById(R.id.map); // Add dynamic layer to MapView map.addLayer(new ArcGISDynamicMapServiceLayer("" + "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")); //Retrieve the non-configuration instance data that was previously returned. Object init = getLastNonConfigurationInstance(); if (init != null) { map.restoreState((String) init); LocationService ls = map.getLocationService(); ls.setAccuracyCircleOn(true); ls.start(); } } protected void onPause() { super.onPause(); map.pause(); } protected void onResume() { super.onResume(); map.unpause(); } }
You could add an if statement to your menu button: LocationService ls = map.getLocationService(); if (ls.isStarted() == false) { ls.start(); } else { ls.stop(); };
LocationService ls = map.getLocationService(); if (ls.isStarted() == false) { ls.start(); } else { ls.stop(); };
//Setting up the button reference ZoomToMyLocation = (Button) findViewById (R.id.button1); //When "Button ZoomToMyLocation" is clicked, method "public void onClick(View v)" gets GPS location. ZoomToMyLocation.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { LocationService ls = map.getLocationService(); ls = map.getLocationService(); if (ls.isStarted() == false){ ls.start(); } else { ls.stop(); }; ls.setAccuracyCircleOn(true); } });
ls = map.getLocationService(); ls.start(); ls.setAccuracyCircleOn(true);
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.