Ok here is what I got so far....The code below is for the .java in source folder.See the red text portion of the code below. Can someone give me advice as to what to put to make the button work?Note: I put TEST for my map service server, so if you copy and paste it want show.package com.dhec.MPOS;
import com.esri.android.map.LocationService;
import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISDynamicMapServiceLayer;
import com.esri.android.map.ags.ArcGISTiledMapServiceLayer;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.LinearUnit;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.geometry.Unit;
import android.app.Activity;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Mapscreen extends Activity {
MapView map = null;
// The circle area specified by search_radius and input lat/lon serves
// searching purpose. It is also used to construct the extent which
// map zooms to after the first GPS fix is retrieved.
final static double SEARCH_RADIUS = 5;
protected static final Intent OnStatusChangedListener = null;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapscreen);
// Retrieve the map and initial extent from XML layout
map = (MapView)findViewById(R.id.map);
// Add dynamic layer to MapView
map.addLayer(new ArcGISTiledMapServiceLayer("" +
"http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
map.addLayer(new ArcGISDynamicMapServiceLayer("" +
"http://TEST/ArcGIS/rest/services/Mobile/MPOS/MapServer"));
//Button Sound
final MediaPlayer buttonSound = MediaPlayer.create(Mapscreen.this, R.raw.watersplash);
//Setting up the button references
Button ZoomToMyLocation = (Button) findViewById (R.id.button3);
//When clicked, Activates the Zoom To GPS process
ZoomToMyLocation.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
buttonSound.start();
//I need the ZoomToMyLocation button to excute here I think?
map.setOnStatusChangedListener(new OnStatusChangedListener(){
//Starts searching for the GPS location of the phone. Below here I've gotten this code to work before, but not
//with my custom button above.
private static final long serialVersionUID = 1L;
public void onStatusChanged(Object source, STATUS status) {
if (source == map && status == STATUS.INITIALIZED) {
LocationService ls = map.getLocationService();
ls.setAutoPan(false);
ls.setLocationListener(new LocationListener() {
boolean locationChanged = false;
// Zooms to the current location when first GPS fix
// arrives.
public void onLocationChanged(Location loc) {
if (!locationChanged) {
locationChanged = true;
double locy = loc.getLatitude();
double locx = loc.getLongitude();
Point wgspoint = new Point(locx, locy);
Point mapPoint = (Point) GeometryEngine
.project(wgspoint,
SpatialReference.create(4326),
map.getSpatialReference());
Unit mapUnit = map.getSpatialReference()
.getUnit();
double zoomWidth = Unit.convertUnits(
SEARCH_RADIUS,
Unit.create(LinearUnit.Code.MILE_US),
mapUnit);
Envelope zoomExtent = new Envelope(mapPoint,
zoomWidth, zoomWidth);
map.setExtent(zoomExtent);
}
}
public void onProviderDisabled(String arg0) {
}
public void onProviderEnabled(String arg0) {
}
public void onStatusChanged(String arg0, int arg1,
Bundle arg2) {
}
});
ls.start();
}
}
});
}});
}
protected void onPause() {
super.onPause();
map.pause();
}
protected void onResume() {
super.onResume();
map.unpause();
}
}