为了将地图对象放置到某个特殊的地理位置上,你需要:

  1. 创建地图对象

  2.添加地图对象到图层(任何位置)

  3. 移动该地图对象,使用 MapObject.moveTo(Location location) 方法

 示例代码:

private void addPOI()
{
   Layer layer = map.getLayerById(SPORTS_LAYER);
   int objectId = 0;
       
   Drawable drawable = getResources().getDrawable(R.drawable.poi_sports);
   MapObject poiSport = new MapObject(objectId,
                                   drawable,
                                       0, 0, // Coordinate in pixels
                                       11, 33, // Pivot point
                                       true, // Touchable
                                       true); // Scalable        
   layer.addMapObject(poiSport);
       
   Location location = new Location("");
   location.setLatitude(51.50844864450185);
   location.setLongitude(-0.16513824462890625);  
   
   // It is obligatory to add map object to the layer before calling
   // moveTo mtehod
   poiSport.moveTo(location);
       
   objectId += 1;
}

 

posted on 2015-08-14 15:13  Joanna.Yan  阅读(623)  评论(0编辑  收藏  举报