Reputation: 65
I am developing an Android app using Skobbler Map.
In my app I want to display lots of custom annotations (png pins). The number of annotations is more than 500 and the pin images get changed in different situations. I am able to add custom annotations, but the app is non responsive for at least 10 seconds when the annotations are rendering (please note that adding annotations takes less than one second, but the rendering takes around 10 seconds - the phone has 3GB RAM).
Here is the relevant code
private void addAnnotations(List<Item> itemList) {
for (Item item : itemList) {
int itemId = item.getItemId();
SKAnnotation annotation = new SKAnnotation(itemId);
annotation.setLocation(new SKCoordinate(item.getLatitude(), item.getLongitude()));
//annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_RED);
SKAnnotationView annotationView = new SKAnnotationView();
RelativeLayout customView = (RelativeLayout) ((LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
R.layout.layout_custom_pin, null, false);
annotationView.setView(customView);
annotationView.setReuseIdentifierWithId("cat." + item.getCategoryId());
annotation.setAnnotationView(annotationView);
mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_NONE);
}
}
If I create 'customView' in above code initially and store it in a member variable and reuse it, then also the result is the same.
Also note that if I use normal pin by calling setAnnotationType with predefined annotation type, it is very fast. Skobbler suggests to use setReuseIdentifierWithId with the same id which I did, I am not sure how and where to use that method. Please note that in my case "item.getCategoryId()" returns the same value for all items in the list.
Can anybody help?
Upvotes: 1
Views: 115
Reputation: 149
I used to get this issue. But using SDK 3.0.3 (latest version from Skobbler team), I managed to get the annotations to load. But there would be a warning on Android Monitor. So i moved the function to a AsyncTask, with a progress bar. It works better. About 2 seconds? And no warning messages.
Upvotes: 1