Search code examples
androidskmaps

SKMaps in Android not displaying annotations


I had created a demo app to known about SKMaps, it worked good with adding annotations. However, now I have moved the code to actual project with the same requirements. Added annotations is not being displayed. I tried with both SKAnnotationView (custom view) and default Annotation type like SKAnnotation.SK_ANNOTATION_TYPE_RED and SKAnnotation.SK_ANNOTATION_TYPE_PURPLE. Nothing is being added to the map.

I have a custom view pager in the same screen, I removed the same and checked still didn't work. SKMapViewHolder is added dynamically.

Code snippet for adding SKMapViewHolder dynamically:

SKMapViewHolder mMapHolder = new SKMapViewHolder(OfflineMapScreen.this);
mMapHolder.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
RelativeLayout outerLayout = (RelativeLayout) findViewById(R.id.outer_layout);
outerLayout.addView(mMapHolder);
RelativeLayout.LayoutParams rlp = (android.widget.RelativeLayout.LayoutParams) mMapHolder.getLayoutParams();
rlp.addRule(RelativeLayout.BELOW, R.id.header);
mMapHolder.setLayoutParams(rlp);

mOSMMapView = mMapHolder.getMapSurfaceView();
mOSMMapView.setMapSurfaceListener(this);
mOSMMapView.getMapSettings().setFollowerMode(SKMapFollowerMode.NONE);
mOSMMapView.getMapSettings().setMapPanningEnabled(true);
mOSMMapView.getMapSettings().setInertiaPanningEnabled(true);
mOSMMapView.getMapSettings().setCompassShown(false);
mOSMMapView.getMapSettings().setCurrentPositionShown(false);
mOSMMapView.setZoomSmooth(14f, 500);

Anybody has the solution for this? Code snippet of adding annotations can be seen here: http://postimg.org/image/sdbwzej9z/


Solution

  • In the image you provided we have noticed that when setting the location you are reusing the same value for both latitude and longitude. Use something like:

     annotationDrawable.setLocation(new SKCoordinate(Double.valueOf(aPlace.getLongitude()),Double.valueOf(aPlace.getLatitude())) ;