打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
如何在图层增加点线面(不通过扩展MapComponent类实现
在实时在线系统中实现地图呈现,所以需根据用户新增操作实时的在地图上增加点线面,下面的代码执行后,不能成功添加对象,不知为什么,请版主帮忙分析一下
layerName = "line_cqt@hzydMap" ;
  IMapService mapService = null;
  String mapName = "hzyd";
  int count = 6;
  Entity[] targetEntities = new Entity[1] ;
  targetEntities[0] = new Entity() ;
  //targetEntities[0].fieldNames = {""};
  //targetEntities[0].fieldValues = {""} ;
  String[] fieldNames = new String[1] ;
  String[] fieldValues = new String[1] ;
  fieldNames[0] = "SmUserId" ;
  fieldValues[0] = "1" ;
  Geometry geo = new Geometry() ;
  geo.feature = FeatureType.LINE ;
  
  MapCoord[] points = new MapCoord[2] ;
  MapCoord point = new MapCoord();
  point.x = new Double(120.1969) ;  point.y = new Double(30.31734) ;
  MapCoord point1 = new MapCoord();
  point1.x = new Double(120.29972) ;  point1.y = new Double(30.51861) ;
  points[0] = point ; points[1] = point ;
  geo.points = points;
  System.out.println(geo) ;
  
  targetEntities[0].shape = geo ;
  targetEntities[0].fieldNames = fieldNames ;
  targetEntities[0].fieldValues = fieldValues ;
  
     
  try {
        mapService = MapServiceFactory.getRemoteMapService("127.0.0.1", 8700, "mapService1", mapName);
        MapParam mapParam = mapService.getDefaultMapParam(mapName) ;
        //得到需添加的基站小区记录
        //调用相应方法在图层上添加地物
        EditResult er = new EditResult()  ;
        er = mapService.addEntity(mapName, layerName, targetEntities, mapParam) ;
        //mapService.u
        System.out.println(er.succeed) ;
        mapService = null ;
  }catch (Exception ex) {
        System.out.println("创建mapService失败") ;
           throw new InstantiationError("创建mapService失败");

  }
 
最后发现是本人粗心,少写了geo.points = points ;造成的
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
400 points 三
400 points 二
400 points
【转载】400 points 一
1986
浴室沉思:为什么鸡蛋尝起来不像鸡肉?
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服