Esri / arcgis-runtime-samples-android

ArcGIS Runtime SDK for Android Samples
https://developers.arcgis.com/android/
Apache License 2.0
666 stars 1.19k forks source link

How to zoom/move to center position of map #158

Closed DucHM closed 8 years ago

DucHM commented 8 years ago

Dear, I have 5 locations any on the map, after I added 5 Marker finished, I want to zoom the map to be able to see all of the 5 points above.

Help me please,

shellygill commented 8 years ago

Hi there - you can see examples of zooming in different ways in various samples - https://github.com/Esri/arcgis-runtime-samples-android/tree/master/SimpleMap and https://github.com/Esri/arcgis-runtime-samples-android/tree/master/Nearby for example.

For general questions like this about how to develop with the ArcGIS Runtime SDK for Android, the best place to ask is on the geonet forum at https://geonet.esri.com/community/developers/native-app-developers/arcgis-runtime-sdk-for-android. This repo is for the samples in particular, so if you have any problems or suggestions for working with the samples in this repo, that's when you should add an issue here.

Closing as geonet question.

DucHM commented 8 years ago

Thank you for feedback, @shellygill

There seems to be some misunderstanding for this. I mean is with the value of any input Location(Dynamic values), the map will automatically adjust the camera edge (adjust the visible region available, Do not use your hands to zoom) just enough to be able to see all the marker.

DucHM commented 8 years ago

You can refer to: https://developers.google.com/android/reference/com/google/android/gms/maps/CameraUpdateFactory.html#public-methods

public static CameraUpdate newLatLngBounds (LatLngBounds bounds, int padding)

Returns a CameraUpdate that transforms the camera such that the specified latitude/longitude bounds are centered on screen at the greatest possible zoom level. You can specify padding, in order to inset the bounding box from the map view's edges. The returned CameraUpdate has a bearing of 0 and a tilt of 0.

shellygill commented 8 years ago

I'm afraid I'm unclear which of the samples in this repo this question relates to - can you clarify that? Are you using the 10.2.8 samples, or the quartz-dev branch?

DucHM commented 8 years ago

I using the 10.2.8 samples and the master branch. I suppose I have 5 or 10 or 20 or n Locations any value is returned from the server. And I add them to the map, i want to map automatically adjusts the angle just enough to be able to observe all of them without manual adjustment.

You can refer to: https://www.youtube.com/watch?v=1yrgnOfhHn8

doneill commented 8 years ago

@DucHM We are still confused as to which sample you are using or extending? The video you reference is not a sample in this repo. Please follow up in the SDK Forum as @shellygill suggests for general inquiries into how to use the SDK.

DucHM commented 8 years ago

Ok, the video you refer is demo my expected.

DucHM commented 8 years ago

In this video: https://www.youtube.com/watch?v=Y_pZF_LkNDk (is a sample in this repo on https://github.com/Esri/arcgis-runtime-samples-android) It does not automatically adjust the visible region available. I must use my hand to perform this.

shellygill commented 8 years ago

Looks like you've made a number of changes to the existing sample, so I cannot say for sure what code you're running to set the extent (visible area) of the mapview. You might find it useful to use the technique from this tutorial - look at step 3 that sets an extent of a map from a number of query results. Once again, I'd suggest this type of question is best asked on the Geonet forum, where your question and any answers can be shared with other users, as others may have similar questions to yours.

DucHM commented 8 years ago

Wow, maybe a good suggestion. I will look this. Thanks

maxime-kouemo commented 7 years ago

I have the same problem using android java. I tried drawing a polygon and getting its envelope. And used

mapView.setViewInsets(
                            envelope.getXMin() - DEFAULT_PADDING,
                            envelope.getYMax() + DEFAULT_PADDING,
                            envelope.getXMax() + DEFAULT_PADDING,
                            envelope.getYMin() - DEFAULT_PADDING);

and I have a very bad zoom (too close) and not displaying the whole graphics. I use 100.1.0 version. Does any one has and answer? Another solution would be to be able to evaluate the scale that I should apply to the mapview once I am able to get the extent of the overlay on which my markers/graphics (coming from google maps) are displayed. Does anyone knows how to get that scale?