View unanswered posts | View active topics It is currently 2020-11-24 17:03



This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
 每次进入退出子网,节点在地图中总是向西北方向移动若干距离 
Author Message
新手上路

Joined: 2011-05-17 13:05
Posts: 37
Post 每次进入退出子网,节点在地图中总是向西北方向移动若干距离
我有这样一个应用,gis坐标从设备中采集,若干设备放在一台车辆中;整个场景有若干辆车。
我考虑采用Subnetwork表示车辆;代表设备的Node必须放置在Subnetwork中;
在拓扑图根视图中显示地图;但进入子网中,将地图图层隐藏掉;
代码如下:

network.addInteractionListener(function(e:InteractionEvent):void {
var element:IElement = e.element;
if(e.kind == "enterSubNetwork") {
if(element != null && element is SubNetwork) {
var isStation:Boolean = element.getClient(IS_STATION);
if(isStation) {
element.setStyle(Styles.BACKGROUND_VECTOR_FILL_ALPHA, 0.8);
center=map.center;
map.removeAllLayers();
map.removeNavigator();
// 禁止通过鼠标滚轮来缩放地图
map.enableWheelOnMap(false);
map.enableZoomAnimation = false;
map.mouseEnabled = false;
map.enablePan(false);
} else {
element.setStyle(Styles.BACKGROUND_VECTOR_FILL_ALPHA, 0);
}
}
}
if(e.kind == "upSubNetwork") {
if(map.getLayer("China") == null) {
if(network.currentSubNetwork != null)
network.currentSubNetwork.setStyle(Styles.BACKGROUND_VECTOR_FILL_ALPHA, 0);
// 恢复通过鼠标滚轮来缩放地图
map.enableWheelOnMap(true);
map.enableZoomAnimation = true;
map.mouseEnabled = true;
map.enablePan(true);

map.installNavigator(25,25);
map.addLayer("China", GISConsts.EXECUTOR_TYPE_GEOSERVER_WMS_4326, gisUrl);
map.center=new GeoCoordinate(center.latitude,center.longitude);
network.elementBox.datas.forEach(function(data:IData):void{
if(data is SubNetwork) {
var node:Element = data as Element;
var longitude:Number = node.getClient(GIS_LONGITUDE);
var latitude:Number = node.getClient(GIS_LATITUDE);
if(longitude > 0 && latitude > 0) {
node.setClient(GISConsts.GEOCOORDINATE, new GeoCoordinate(latitude, longitude));
}
}
});
}
}
});

但在测试中,发现一个严重问题,每次从子网中退出到根视图,所有节点(都是Subnetwork)在地图中的坐标,都向西北方向移动若干距离,而且每次移动距离固定,与地图放大尺寸没有关系。
请问这是怎么回事?
Flex版的。


2015-05-05 10:19
Profile
新手上路

Joined: 2011-05-17 13:05
Posts: 37
Post Re: 每次进入退出子网,节点在地图中总是向西北方向移动若干距离
地图使用超图,下载地址:
http://support.supermap.com.cn/ProductC ... spx?id=108
地图初始化过程:
map.installNavigator(25,25);
adapter = new Adapter();
adapter.bindNetworkWithTWaverMap(map,network);
map.addLayer("China", GISConsts.EXECUTOR_TYPE_GEOSERVER_WMS_4326, gisUrl);
var zoomLevel:int = 4;
if(network.elementBox.getClient(GIS_ZOOM_LEVEL) != null) {
zoomLevel = network.elementBox.getClient(GIS_ZOOM_LEVEL) as int;
}
map.zoomLevel = zoomLevel;
if(network.elementBox.getClient(GIS_LONGITUDE) != null && network.elementBox.getClient(GIS_LATITUDE) != null) {
var longitude:Number = network.elementBox.getClient(GIS_LONGITUDE);
var latitude:Number = network.elementBox.getClient(GIS_LATITUDE);
if(longitude > 0 && latitude > 0) {
center = new GeoCoordinate(latitude, longitude);
}
}
map.center = center;
其中变量gisUrl取值如下:
http://192.168.0.131:8090/iserver/servi ... s130/China?
地图China为超图自带的默认地图。


2015-05-05 11:13
Profile
TWaver开发组
User avatar

Joined: 2014-02-11 8:59
Posts: 575
Post Re: 每次进入退出子网,节点在地图中总是向西北方向移动若干距离
您提供的demo我没运行起来,不过感觉有可能是关闭map和启动map之间经纬度的精确度问题导致的,向西北方向,有可能是x取整,y也取整导致的。


2015-05-11 21:41
Profile
新手上路

Joined: 2011-05-17 13:05
Posts: 37
Post Re: 每次进入退出子网,节点在地图中总是向西北方向移动若干距离
那怎么处理呢?

Subnetwork的gis坐标,来源于节点的移动,见如下代码:
network.elementBox.addDataPropertyChangeListener(locationChanged);

private function locationChanged(e:PropertyChangeEvent):void{
var target:Object = e.source;
var newValue:Object = e.newValue;
network.elementBox.datas.forEach(function(data:IData):void{
if(data is SubNetwork) {
var node:SubNetwork = data as SubNetwork;
var nodeGeo:GeoCoordinate = map.getGeoPointFromPointOnMap(node.location.x, node.location.y);
node.setClient(GIS_LONGITUDE, nodeGeo.longitude);
node.setClient(GIS_LATITUDE, nodeGeo.latitude);
}
});
}


2015-05-12 9:26
Profile
白金会员

Joined: 2013-05-20 10:09
Posts: 1045
Post Re: 每次进入退出子网,节点在地图中总是向西北方向移动若干距离
您好,解决方案昨天已经发到您邮箱里了。


2015-05-20 10:01
Profile
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron