zoukankan      html  css  js  c++  java
  • Android基于mAppWidget实现手绘地图(七)–根据坐标添加地图对象

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

      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;
    }
  • 相关阅读:
    12.如何设置ulimit
    11.vim常用操作
    01Java jdk环境配置
    css
    Html
    day07 Class_field_method_反射
    JDBC
    Oracle day05 索引_数据去重
    Oracle day05 建表_约束
    Oracle day04 DML_事务_序列_视图_数据类型_DDL
  • 原文地址:https://www.cnblogs.com/Joanna-Yan/p/4730058.html
Copyright © 2011-2022 走看看