0
votes

I have locally stored about 1200 anotation data in an array. Now I want to add/set only annotation to region that is presently viewing. When user updates the region this will add/set new annotations. I know we can implement this in regionChanged method. I want this to be loading fast. Please suggest me how can we implement this that will be efficient. Also please suggest me which will be fast enough Loading annotation in single time with

mapview.setAnnotations(annotationarray);

or showing as region wise. The default zoom level of application is as this will have only 2-4 annotation at a time. sorry for multiple question in single time.

1

1 Answers

0
votes

With your current region and the latitudeDelta and longitudeDelta you can deduce what your current map bounding box is (that's the coordinates of the 4 corners of your current mapview).

You should check if the coordinates of each of your pins is within the bounding box and then if it is inside save it in a separate array. Once you finished the check add that array of annotations to the mapview.

Each time the region changes you should repeat this operation.

I don't know how efficient this solution is, but iterating through an array of 1200 items is not going to be inexpensive.

If this solution is very slow, you could also save the coordinates in a sqlite database and execute a query each time.