Hi Guys
I am new bee to ArcGis. I am developing ArcGis map in my Android app. may is displayed using one url in ArcGISTiledMapServiceLayer
this is my code fragment----
setContentView(R.layout.main);
mMapView = (MapView) findViewById(R.id.map);
mMapView.addLayer(new ArcGISTiledMapServiceLayer(
"http://maps.ocparks.com/arcgis/rest/services/Imagery/2013_Imagery/MapServer"));
along with this url I am using some other urls for adding layers on map in ArcGISFeatureLayer. All is working good. now I want to show current location of device on this Map. after going through several tutorials and documentations I came to know that for displaying location we must use
mMapView.addLayer(new ArcGISTiledMapServiceLayer(
"
http://services.arcgisonline.com/ArcGIS/rest/services/
World_Street_Map/MapServer
"));
so guys if there is any possible way to locate device location on ArcGis Imagery map.(not world_Street_map)
Solved! Go to Solution.
Your description of the problem is somewhat vague... do you mean you want to be able to use device GPS to locate yourself on map?
You need to use LocationDisplayManager - here is some code from my app
// In case you need it later, make it class variable
LocationDisplayManager lDisplayManager = null;
// ... inside onCreate(), after your .addlayers
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
@Override
public void onStatusChanged(Object source, STATUS status) {
if (source == mMapView && status == STATUS.INITIALIZED) {
lDisplayManager = mMapView.getLocationDisplayManager();
lDisplayManager.setAutoPanMode(LocationDisplayManager.AutoPanMode.LOCATION);
lDisplayManager.setLocationListener(new LocationListener() {
boolean locationChanged = false;
// Zooms to the current location when first GPS fix arrives.
@Override
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),
mMapView.getSpatialReference());
Unit mapUnit = mMapView.getSpatialReference()
.getUnit();
double zoomWidth = Unit.convertUnits(
5,
Unit.create(LinearUnit.Code.MILE_US),
mapUnit);
Envelope zoomExtent = new Envelope(mapPoint,
zoomWidth, zoomWidth);
mMapView.setExtent(zoomExtent);
}
}
@Override
public void onProviderDisabled(String arg0) {
}
@Override
public void onProviderEnabled(String arg0) {
}
@Override
public void onStatusChanged(String arg0, int arg1,
Bundle arg2) {
}
}); // Actionlistener
lDisplayManager.start();
}
}
}
if (source == mMapView && status == STATUS.LAYER_LOADED) {
}
}
}
});
There might be some extra } or { as I copy pasted it from the code and had to remove some special stuff related to our app.
HTH.
Your description of the problem is somewhat vague... do you mean you want to be able to use device GPS to locate yourself on map?
You need to use LocationDisplayManager - here is some code from my app
// In case you need it later, make it class variable
LocationDisplayManager lDisplayManager = null;
// ... inside onCreate(), after your .addlayers
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
@Override
public void onStatusChanged(Object source, STATUS status) {
if (source == mMapView && status == STATUS.INITIALIZED) {
lDisplayManager = mMapView.getLocationDisplayManager();
lDisplayManager.setAutoPanMode(LocationDisplayManager.AutoPanMode.LOCATION);
lDisplayManager.setLocationListener(new LocationListener() {
boolean locationChanged = false;
// Zooms to the current location when first GPS fix arrives.
@Override
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),
mMapView.getSpatialReference());
Unit mapUnit = mMapView.getSpatialReference()
.getUnit();
double zoomWidth = Unit.convertUnits(
5,
Unit.create(LinearUnit.Code.MILE_US),
mapUnit);
Envelope zoomExtent = new Envelope(mapPoint,
zoomWidth, zoomWidth);
mMapView.setExtent(zoomExtent);
}
}
@Override
public void onProviderDisabled(String arg0) {
}
@Override
public void onProviderEnabled(String arg0) {
}
@Override
public void onStatusChanged(String arg0, int arg1,
Bundle arg2) {
}
}); // Actionlistener
lDisplayManager.start();
}
}
}
if (source == mMapView && status == STATUS.LAYER_LOADED) {
}
}
}
});
There might be some extra } or { as I copy pasted it from the code and had to remove some special stuff related to our app.
HTH.
This code fragment only works with World_Street_Map server not with Imagery Map service