我想在地图上显示标记,但是没有显示,这是我使用的代码, 我正在使用HERE Map SDK for Android
Image img = new Image();
try {
img.setImageResource(R.drawable.marker);
} catch (IOException e) {
e.printStackTrace();
}
MapMarker mm = new MapMarker();
mm.setIcon(img);
mm.setCoordinate(new GeoCoordinate(21.609512, 39.131269));
答案 0 :(得分:3)
创建MapMarker后,您还需要通过Map.addMapObject(...)将其添加到地图中
请参阅我的示例(其中mMap是我的Map实例,锚点位于botton而不是center):
private void addMarker(GeoCoordinate geoCoordinate)
{
if (mMarker == null) {
Image image = new Image();
try {
image.setImageResource(R.drawable.pin);
} catch (final IOException e) {
e.printStackTrace();
}
mMarker = new MapMarker(geoCoordinate, image);
mMarker.setAnchorPoint(new PointF(image.getWidth()/2, image.getHeight()));
mMap.addMapObject(mMarker);
} else {
mMarker.setCoordinate(geoCoordinate);
}
mMap.setCenter(geoCoordinate, Animation.BOW);
}