Hello,
I keep trying to zoom into a coordinate using the zoomTo(Point centerPt, float factor) public methoHowever, everytime i run my application, the map starts of the coast of africa. Has anyone had this issue before? Maybe my code is not correct.
Solved! Go to Solution.
Hi Thomas,
In your code, looks like you have the X and Y the wrong way around, assuming that the Point you're creating is supposed to be in a geographical coordinate system - e.g. the coordinates are latitude and longitude, like from GPS position. The X-axis of the coordinate system is the longitude - for WGS 84 coordinate system, this would be a value from -180 to +180, and the first parameter in point constructor is the x value. The y-axis is latitude, -90 to +90, and the second parameter in the constructor.
I cant tell from your code what coordinate system your map is in - it will be the same coordinate system as that first layer that you add. So as long as that is geographic coordinate system as well, that will work - you need to zoom to a point that is in the same coordinate system as the map.
Hope this helps,
Shelly
this is my code:
double xCoordinate = 34.171604; double yCoordinate = -117.317647; Point point = new Point(xCoordinate,yCoordinate); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Retrieve the map and initial extent from XML layout mMapView = (MapView) findViewById(R.id.map); mMapView.zoomToResolution(point, 15); //retrieve layer from server mFeatureServiceUrl = this.getResources().getString(R.string.campus); mFeatureLayer = new ArcGISFeatureLayer(mFeatureServiceUrl, ArcGISFeatureLayer.MODE.ONDEMAND); //add the layer to the mapView mMapView.addLayer(mFeatureLayer); mGraphicsLayer = new GraphicsLayer(); mMapView.addLayer(mGraphicsLayer);
Its
mMapView.zoomToScale(point, 15); not
mMapView.zoomToResolution(point, 15);
but it still doesnt work.
Hi Thomas,
In your code, looks like you have the X and Y the wrong way around, assuming that the Point you're creating is supposed to be in a geographical coordinate system - e.g. the coordinates are latitude and longitude, like from GPS position. The X-axis of the coordinate system is the longitude - for WGS 84 coordinate system, this would be a value from -180 to +180, and the first parameter in point constructor is the x value. The y-axis is latitude, -90 to +90, and the second parameter in the constructor.
I cant tell from your code what coordinate system your map is in - it will be the same coordinate system as that first layer that you add. So as long as that is geographic coordinate system as well, that will work - you need to zoom to a point that is in the same coordinate system as the map.
Hope this helps,
Shelly
Thank you!!