Goldmap 应用程序接口的开发和编码
最编程
2024-03-28 18:08:13
...
/** 高德autonavi 地图API Define:begin */
var AutoNaviMap = function(mapOption){
this.map = null; //高德autonavi地图对象
this.mapWrap = mapOption.mapWrap; //地图容器
this.mapRange = mapOption.mapRange; //地图范围
this.centerPoint = mapOption.centerPoint; //中心点
this.GeoServerLayers = mapOption.GeoServerLayers; //GeoServer 图层参数
this.GeoServerlayerEntities = null; //GeoServer 图层实例对象
this.zoom = mapOption.zoom==undefined ? 15 : mapOption.zoom;
this.contextMenuPositon; //右键菜单位置
this.mapLayer;//管线图层
this.heatmap;
this.toolBar = null; // 地图oolBar插件
this.markers = [];
this.infoWindow = {}; //global infoWindow
this.polygon;
this.init = function(){
debugger;
var self = this;
if(!self.map){
var option = {resizeEnable : true, //监控地图容器尺寸变化,默认为false
zoom : self.zoom, //显示级别
mapStyle: "amap://styles/darkblue", //地图样式主题
features:['bg', 'point', 'building'], //地图展示元素
logo : false};
if(self.centerPoint && !$.isEmptyObject(self.centerPoint)){ //设置中心点
var transCoordinate = {
'lng':self.centerPoint.x,
'lat':self.centerPoint.y
};
if(!mapOption.noTransAmap) {
self.centerPoint.lng = self.centerPoint.x;
self.centerPoint.lat = self.centerPoint.y;
transCoordinate = self.get_GCJLngLat(self.centerPoint);
}
option['center'] = new AMap.LngLat(transCoordinate.lng, transCoordinate.lat);
}
self.map = new AMap.Map(self.mapWrap, option);
//地图单击事件
if(mapOption.click && $.isFunction(mapOption.click)) {
debugger;
self.map.on('click',function(e){
var mapPoint = getMapPoint(e); //经纬度
var screenPoint = getScreenPoint(e);
mapOption.click(mapPoint, screenPoint);
}); //点事件的获取
}
//地图缩放结束事件
if(mapOption.zoomend && $.isFunction(mapOption.zoomend)) {
self.map.on('zoomend',function(e){
mapOption.zoomend();
}); //点事件的获取
}
self.map.plugin(["AMap.ToolBar"], function() {
toolBarOption = {
offset:new AMap.Pixel(10,50)
}
toolBar = new AMap.ToolBar(toolBarOption);
self.map.addControl(toolBar);
});
//添加比例尺控件
self.map.plugin(["AMap.Scale"],function(){
self.map.addControl(new AMap.Scale());
});
//地图类型切换
self.map.plugin(["AMap.MapType"],function(){
var type= new AMap.MapType({
defaultType:0 //使用2D地图
});
self.map.addControl(type);
});
$(".amap-maptype-wrap").bind('click',function(){
if(self.mapLayer && self.map){
self.mapLayer.setMap(self.map);
}
}); // 绑定地图切换插件单击事件
}
//在高德地图上 叠加 标准wms图层
setTimeout(function(){
if(self.GeoServerLayers && self.GeoServerLayers.length>0){
self.GeoServerlayerEntities = {};
for(var i=0,len=self.GeoServerLayers.length; i<len; i++){
var geoItem = self.GeoServerLayers[i];
// 创建 WMS 标准图层
var version = geoItem.GeoServerVersion || '1.1.0';
var wms = new AMap.TileLayer.WMS({
url: geoItem.GeoServerLayerUrl,
blend: true,
tileSize: 256,
visible: false,
params: {'LAYERS': geoItem.GeoServerLayerName,VERSION:version}
});
self.GeoServerlayerEntities[geoItem.GeoServerLayerCode] = wms;
//wms.show();
wms.setMap(self.map);
}
}
}, 1000);
if(mapOption.openSatelliteLayer){
var satelliteLayer = new AMap.TileLayer.Satellite();
var roadNetLayer = new AMap.TileLayer.RoadNet();
var layers = [
satelliteLayer
]
// 添加到地图上
self.map.add(layers);
}
};
/**
* checkType : 选中还是取消选中
*/
this.geoAllLayerVisibleOrHide = function(checkType){
var self = this;
var _GeoServerlayerEntities = self.GeoServerlayerEntities;
for(var o in _GeoServerlayerEntities){
if(checkType){
_GeoServerlayerEntities[o].show();
}else{
_GeoServerlayerEntities[o].hide();
}
}
}
/**
* 控制geoServer图层 显示与隐藏
* pipeCode : 管线压力级制编码
* checkType : 选中还是取消选中
*/
this.geoServerLayerVisibleOrHide = function(pipeCode, checkType){
var self = this;
var _GeoServerlayerEntities = self.GeoServerlayerEntities;
var glayer = _GeoServerlayerEntities[pipeCode];
if(checkType){
glayer.show();
}else{
glayer.hide();
}
};
this.drawPolygon = function(mPolygon){
var _self = this;
var coordinatesList = [];
if (mPolygon.points.length > 0) {
$.each(mPolygon.points, function(coordinateIndex, coordinateEntry) {
if(coordinateEntry.lng && coordinateEntry.lat && Number(coordinateEntry.lng)>0 && Number(coordinateEntry.lat)>0){
var transCoordinate = {
'lng':coordinateEntry.lng,
'lat':coordinateEntry.lat
}
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!mPolygon.noTransAmap) {
var transCoordinate = _self.get_GCJLngLat(coordinateEntry);
}
coordinatesList.push(new AMap.LngLat(transCoordinate.lng, transCoordinate.lat));
}
});
if(coordinatesList.length>0) {
polygon = new AMap.Polygon({
map:_self.map,
path: coordinatesList,//设置多边形边界路径
strokeColor: mPolygon.color?mPolygon.color:"#FF33FF", //线颜色
strokeOpacity: mPolygon.opacity?mPolygon.opacity:0.2, //线透明度
strokeWeight: mPolygon.width?mPolygon.width:3, //线宽
fillColor: mPolygon.fillColor?mPolygon.fillColor:"#1791fc", //填充色
fillOpacity: mPolygon.fillOpacity?mPolygon.fillOpacity:0.35,//填充透明度
zIndex:mPolygon.zIndex
});
}
}
return polygon;
};
this.drawLine = function(mLine){
var _self = this;
var polyLine;
var coordinatesList = [];
if (mLine.pionts.length > 0) {
$.each(mLine.pionts, function(coordinateIndex, coordinateEntry) {
if(coordinateEntry.lng && coordinateEntry.lat && Number(coordinateEntry.lng)>0 && Number(coordinateEntry.lat)>0){
var transCoordinate = {
'lng':coordinateEntry.lng,
'lat':coordinateEntry.lat
}
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!mLine.noTransAmap) {
var transCoordinate = _self.get_GCJLngLat(coordinateEntry);
}
coordinatesList.push(new AMap.LngLat(transCoordinate.lng, transCoordinate.lat));
}
});
if(coordinatesList.length>0) {
polyLine = new AMap.Polyline({
id : mLine.id,
map:_self.map,
path: coordinatesList, //设置线覆盖物路径
strokeColor: mLine.color, //线颜色
strokeOpacity: mLine.opacity, //线透明度
strokeWeight: mLine.width, //线宽
strokeStyle: mLine.style, //线样式
strokeDasharray: mLine.dasharray //补充线样式
});
}
if(mLine.infowindow && !$.isEmptyObject(mLine.infowindow)) {
if(!$('body').find('#infowindow').length>0) {
var html = '<div id="infowindow" style="position:absolute;display:none" class="box_wraper"><div class="box_con"><p></p></div><div class="box_img"><img src="/HRSmartGas/platform/images/box_img.png"/></div></div>';
$('body').append(html);
}
polyLine.on('mouseover',function(e) {
$('body').find('#infowindow p').html(mLine.infowindow.content);
$('#infowindow').show();
$('#infowindow').css("left",e.pixel.x-$('#infowindow').width()/2);
$('#infowindow').css("top",e.pixel.y-$('#infowindow').height());
});
polyLine.on('mouseout',function(e) {
$('#infowindow').hide();
});
}
if(mLine.onClick){
polyLine.on('click',function(e) {
mLine.onClick(e);
});
}
}
return polyLine;
};
/**
* 删除点
* point 为map地图对象, drawPoint时返回
*/
this.removePoint = function(point){
this.map.remove(point);
};
this.removeLine = function(mLine){
var _self = this;
_self.map.remove(mLine);
};
this.removePolygon = function(polygon){
var _self = this;
_self.map.remove(polygon);
};
this.drawPoint = function(mPoint){
debugger;
var _self = this;
var transCoordinate = {
'lng':mPoint.lng,
'lat':mPoint.lat
};
var marker;
if(mPoint.lng && mPoint.lat && Number(mPoint.lng)>0 && Number(mPoint.lat)>0){
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!mPoint.noTransAmap) {
transCoordinate = _self.get_GCJLngLat(mPoint);
}
var icon;
if(mPoint.type.imgUrl == "") {
icon = new AMap.Icon({
imageSize:new AMap.Size(mPoint.type.width,mPoint.type.height),
size: new AMap.Size(mPoint.type.width,mPoint.type.height), //图标大小
});
} else {
icon = new AMap.Icon({
imageSize:new AMap.Size(mPoint.type.width,mPoint.type.height),
size: new AMap.Size(mPoint.type.width,mPoint.type.height), //图标大小
image:mPoint.type.imgUrl
});
}
var pointOpitons = {
map:_self.map,
icon:icon,
position:[transCoordinate.lng,transCoordinate.lat],
offset:new AMap.Pixel(mPoint.type.xoffset, mPoint.type.yoffset), //偏移量
title:mPoint.type.title, //点的文字提示
extData:mPoint
};
marker = new AMap.Marker(pointOpitons);
mPoint.marker = marker;
if(mPoint.type.onClick && $.isFunction(mPoint.type.onClick)) {
marker.on('click',function(e){
debugger;
mPoint.type.onClick(e.target.getExtData(),null);
}); //点事件的获取
}
if(null != mPoint.labelContent && '' != mPoint.labelContent && 'undefined' != mPoint.labelContent){
marker.setLabel({
offset: new AMap.Pixel(20, -10), //显示位置
content: mPoint.labelContent //显示内容
});
}
_self.markers.push(mPoint);
}
if(mPoint.type.showInfo && mPoint.type.infowindow && !$.isEmptyObject(mPoint.type.infowindow)) {
debugger;
if(marker != undefined) {
var position = {
'lng':mPoint.lng,
'lat':mPoint.lat
};
if(!mapOption.noTransAmap) {
position = _self.get_GCJLngLat({'lng':mPoint.lng,'lat':mPoint.lat});
}
var infowindow = mPoint.type.infowindow;
var infoMouseOverWin = new AMap.InfoWindow({
isCustom:true,
content: infowindow.content,
offset: new AMap.Pixel(infowindow.xoffset,infowindow.yoffset)
});
infoMouseOverWin.open(_self.map, new AMap.LngLat(position.lng,position.lat));
_self.infoWindow.uniqueCode = mPoint.busiKey;
}
}
};
/**
* 展示自定义弹出框
*/
this.showInfoWindow = function(mPoint){
debugger;
var _self = this;
if(mPoint.type.infowindow && !$.isEmptyObject(mPoint.type.infowindow)) {
var position = {
'lng':mPoint.lng,
'lat':mPoint.lat
};
if(!mapOption.noTransAmap) {
position = _self.get_GCJLngLat({'lng':mPoint.lng,'lat':mPoint.lat});
}
var infowindow = mPoint.type.infowindow;
var infoMouseOverWin = new AMap.InfoWindow({
isCustom:true,
content: infowindow.content,
offset: new AMap.Pixel(infowindow.xoffset,infowindow.yoffset)
});
infoMouseOverWin.open(_self.map, new AMap.LngLat(position.lng,position.lat));
_self.infoWindow.uniqueCode = mPoint.busiKey;
}
}
this.getInfoWindowUnique = function(){
var _self = this;
return _self.infoWindow.uniqueCode;
}
this.clearGraphics = function(type) {
var _self = this;
for(var i =0; i<_self.markers.length; i++){
if(type){
if((_self.markers[i].node == type))
_self.map.remove(_self.markers[i].marker);
}else{
_self.map.remove(_self.markers[i].marker);
}
}
};
/**
* e 鼠标事件对象
*/
function getScreenPoint(e){
return new SreenPoint({x:e.pixel.x, y:e.pixel.y});
};
/**
* e 鼠标事件对象
*/
function getMapPoint(e){
return new MapPoint({'lng' : e.lnglat.lng, 'lat' : e.lnglat.lat});
};
//绘制管线图层
this.drawArcgisTile = function(url,token,callback) {
var _self = this;
if(_self.mapLayer){
mapLayer.setTileUrl(callback);
} else {
_self.mapLayer = new AMap.TileLayer({
zIndex:20,
getTileUrl: function(x,y,z){
return url+'/'+ z +'/'+ y +'/'+ x+'?token='+token;
}
});
_self.mapLayer.setMap(_self.map);
}
return _self.mapLayer;
};
//重新加载arcgis管线图层
this.reloadArcgisTile = function(){
if(_self.mapLayer && _self.map){
_self.mapLayer.setMap(_self.map);
}
}
//画热力图
this.drawHeatMap = function(heatMap) {
var _self = this;
var coordinatesList = [];
if (heatMap.data.length > 0) {
$.each(heatMap.data, function(coordinateIndex, coordinateEntry) {
if(coordinateEntry.lng && coordinateEntry.lat && Number(coordinateEntry.lng)>0 && Number(coordinateEntry.lat)>0){
var transCoordinate = {
'lng':coordinateEntry.lng,
'lat':coordinateEntry.lat
}
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!heatMap.noTransAmap) {
transCoordinate = _self.get_GCJLngLat(coordinateEntry);
}
coordinatesList.push(new AMap.LngLat(transCoordinate.lng, transCoordinate.lat));
}
});
}
if(coordinatesList.length>0) {
_self.map.plugin(["AMap.Heatmap"], function() {
//初始化heatmap对象
_self.heatmap = new AMap.Heatmap(_self.map, {
radius: 80, //给定半径
opacity: [0, 0.8]
});
//设置数据集
_self.heatmap.setDataSet({
data: coordinatesList,
max: 2
});
});
}
}
/**
*画圆 获取中心点及半径
*20180122
*/
this.draw =function (){
var _self = this;
var mouseTool = new AMap.MouseTool(_self.map);
//自定义图形样式
mouseTool.polyline({
strokeColor:"#f50", // 线条颜色,十六进制
strokeOpacity:0.5, // 线条透明度
strokeWeight:10, // 线条宽度
strokeStyle:"dashed" // 线条样式 solid || dashed
});
//在地图中添加MouseTool插件
mouseTool.circle(); //用鼠标工具画圆
AMap.event.addListener( mouseTool,'draw',function(e){ //添加事件
console.log(e.obj.getRadius());//获取半径
console.log(e.obj.getCenter());//获取中心点
showChoseDevice(e.obj.getRadius(),e.obj.getCenter());
mouseTool.close(true);//关闭当前鼠标操作
});
} ;
//画圆
this.drawCircle = function(circle){
var _self = this;
var center = new AMap.LngLat(circle.center.lng,circle.center.lat);
var circleOptions = {
center:center,
zIndex:1000,
radius:circle.radius, //半径1公里
strokeColor: "#F33", //线颜色
strokeOpacity: 1, //线透明度
strokeWeight: 3, //线粗细度
fillColor: "#ee2200", //填充颜色
fillOpacity: 0.35//填充透明度
};
var _circle = new AMap.Circle(circleOptions);
_circle.setMap(_self.map);
circle.marker = _circle;
}
this.circleContains = function(circle,point) {
var _self = this;
var transCoordinate = {
'lng':point.lng,
'lat':point.lat
}
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!point.noTransAmap) {
transCoordinate = _self.get_GCJLngLat(point);
}
var _point = new AMap.LngLat(transCoordinate.lng,transCoordinate.lat);
var isContains = circle.marker.contains(_point);
return isContains;
}
//绑定地图缩放事件
this.bindZoomChange = function(callBack) {
var _self = this;
_self.map.on('zoomchange', function(e) {
callBack(_self.map.getZoom());
});
}
//绑定地图单击事件
this.bindClick = function(callBack) {
var _self = this;
_self.map.on('click', function(e) {
callBack(e.lnglat.getLng(),e.lnglat.getLat(),_self.map.getZoom());
});
}
/**
* 获取缩放等级
*/
this.getZoom = function(){
var _self = this;
return _self.map.getZoom();
}
//显示或隐藏热力图
this.showHeatMap = function(isShow) {
var _self = this;
if(_self.heatmap) {
if(isShow) {
_self.heatmap.show();
} else {
_self.heatmap.hide();
}
}
}
//添加右键菜单获取坐标
this.addGetLnglatMenu = function() {
var _self = this;
var menu = new AMap.ContextMenu();
//添加菜单项
menu.addItem("发送任务",function() {
debugger;
mapDbClick(contextMenuPositon.getLat(),contextMenuPositon.getLng());
//alert(contextMenuPositon.getLng() + "," + contextMenuPositon.getLat());
},0);
//为地图注册rightclick事件获取鼠标点击出的经纬度坐标
var clickEventListener = _self.map.on('rightclick', function(e) {
menu.open(_self.map,e.lnglat);
contextMenuPositon = e.lnglat;
});
};
this.setCenter = function(lnt,lat) {
var transCoordinate = {
'lng':lnt,
'lat':lat
};
var _self = this;
if(!mapOption.noTransAmap) {
_self.centerPoint.lng = lnt;
_self.centerPoint.lat = lat;
transCoordinate = _self.get_GCJLngLat(_self.centerPoint);
}
_self.map.setCenter(new AMap.LngLat(transCoordinate.lng, transCoordinate.lat));
};
this.closeInfoWindow = function(infoWindow) {
var _self = this;
_self.map.clearInfoWindow();
};
this.fromLngLatToContainerPixel = function(mPoint) {
var _self = this;
var retObj = _self.map.lnglatToPixel(new AMap.LngLat(mPoint.lng,mPoint.lat));
return new SreenPoint(retObj);
};
this.fromContainerPixelToLngLat = function(mPoint) {
var _self = this;
var retObj = _self.map.pixelToLngLat(new AMap.Pixel(mPoint.x,mPoint.y));
return new MapPoint(retObj);
};
this.setFitView = function() {
var _self = this;
_self.map.setFitView();
};
this.zoomOut = function() {
var _self = this;
_self.map.zoomOut();
}
this.get_GCJLngLat = function(mPoint) {
var retObj = {};
var CT = new CoordinateTransform(mPoint.lat, mPoint.lng, CoordinateSys.WGS84);//CoordinateSys.WGS84 是转换前的坐标系
var retValue = new Object();
if (CT.WGS84ToGCJ02()== false)//WGS84ToBD09()方法 WGS84转BD坐标,如果是转成火星坐标改调用WGS84ToGCJ02()
console.info(CT.get_ErrMsg());
retObj.lat = CT.get_GCJLat() == 0 ? mPoint.lat : CT.get_GCJLat();//获取转换后的高德坐标纬度
retObj.lng = CT.get_GCJLng() == 0 ? mPoint.lng : CT.get_GCJLng();//获取转换后的高德坐标精度
return retObj;
};
};
function openWindowTask(tltle,url){
var options = {
modal : true,
title : tltle,
collapsible : false,
minimizable : false,
maximizable : false,
closable : true,
closed : false
};
var uid = "self_card_";
options["id"] = uid;
winFormDesigner = UIFactory.getUI(uid);
if(!winFormDesigner){
winFormDesigner = UIFactory.create(xpad.ui.Window, options);
}
var root = jQuery("body");
var offset = root.offset();
var winleft = 0;
var wintop = 0;
var newSize = {};
newSize["left"] = (jQuery("body").width()-450)/2;
newSize["top"] = 20;
newSize["width"] = 450;//jQuery("body").width();
newSize["height"] = 500;//jQuery("body").height();
winFormDesigner.window("resize", newSize);
setTimeout(function(){
winFormDesigner.loadURL(url);
}, 0);
}
AutoNaviMap.CLASS_NAME = "AutoNaviMap";
/**高德autonavi 地图API Define:end */
var AutoNaviMap = function(mapOption){
this.map = null; //高德autonavi地图对象
this.mapWrap = mapOption.mapWrap; //地图容器
this.mapRange = mapOption.mapRange; //地图范围
this.centerPoint = mapOption.centerPoint; //中心点
this.GeoServerLayers = mapOption.GeoServerLayers; //GeoServer 图层参数
this.GeoServerlayerEntities = null; //GeoServer 图层实例对象
this.zoom = mapOption.zoom==undefined ? 15 : mapOption.zoom;
this.contextMenuPositon; //右键菜单位置
this.mapLayer;//管线图层
this.heatmap;
this.toolBar = null; // 地图oolBar插件
this.markers = [];
this.infoWindow = {}; //global infoWindow
this.polygon;
this.init = function(){
debugger;
var self = this;
if(!self.map){
var option = {resizeEnable : true, //监控地图容器尺寸变化,默认为false
zoom : self.zoom, //显示级别
mapStyle: "amap://styles/darkblue", //地图样式主题
features:['bg', 'point', 'building'], //地图展示元素
logo : false};
if(self.centerPoint && !$.isEmptyObject(self.centerPoint)){ //设置中心点
var transCoordinate = {
'lng':self.centerPoint.x,
'lat':self.centerPoint.y
};
if(!mapOption.noTransAmap) {
self.centerPoint.lng = self.centerPoint.x;
self.centerPoint.lat = self.centerPoint.y;
transCoordinate = self.get_GCJLngLat(self.centerPoint);
}
option['center'] = new AMap.LngLat(transCoordinate.lng, transCoordinate.lat);
}
self.map = new AMap.Map(self.mapWrap, option);
//地图单击事件
if(mapOption.click && $.isFunction(mapOption.click)) {
debugger;
self.map.on('click',function(e){
var mapPoint = getMapPoint(e); //经纬度
var screenPoint = getScreenPoint(e);
mapOption.click(mapPoint, screenPoint);
}); //点事件的获取
}
//地图缩放结束事件
if(mapOption.zoomend && $.isFunction(mapOption.zoomend)) {
self.map.on('zoomend',function(e){
mapOption.zoomend();
}); //点事件的获取
}
self.map.plugin(["AMap.ToolBar"], function() {
toolBarOption = {
offset:new AMap.Pixel(10,50)
}
toolBar = new AMap.ToolBar(toolBarOption);
self.map.addControl(toolBar);
});
//添加比例尺控件
self.map.plugin(["AMap.Scale"],function(){
self.map.addControl(new AMap.Scale());
});
//地图类型切换
self.map.plugin(["AMap.MapType"],function(){
var type= new AMap.MapType({
defaultType:0 //使用2D地图
});
self.map.addControl(type);
});
$(".amap-maptype-wrap").bind('click',function(){
if(self.mapLayer && self.map){
self.mapLayer.setMap(self.map);
}
}); // 绑定地图切换插件单击事件
}
//在高德地图上 叠加 标准wms图层
setTimeout(function(){
if(self.GeoServerLayers && self.GeoServerLayers.length>0){
self.GeoServerlayerEntities = {};
for(var i=0,len=self.GeoServerLayers.length; i<len; i++){
var geoItem = self.GeoServerLayers[i];
// 创建 WMS 标准图层
var version = geoItem.GeoServerVersion || '1.1.0';
var wms = new AMap.TileLayer.WMS({
url: geoItem.GeoServerLayerUrl,
blend: true,
tileSize: 256,
visible: false,
params: {'LAYERS': geoItem.GeoServerLayerName,VERSION:version}
});
self.GeoServerlayerEntities[geoItem.GeoServerLayerCode] = wms;
//wms.show();
wms.setMap(self.map);
}
}
}, 1000);
if(mapOption.openSatelliteLayer){
var satelliteLayer = new AMap.TileLayer.Satellite();
var roadNetLayer = new AMap.TileLayer.RoadNet();
var layers = [
satelliteLayer
]
// 添加到地图上
self.map.add(layers);
}
};
/**
* checkType : 选中还是取消选中
*/
this.geoAllLayerVisibleOrHide = function(checkType){
var self = this;
var _GeoServerlayerEntities = self.GeoServerlayerEntities;
for(var o in _GeoServerlayerEntities){
if(checkType){
_GeoServerlayerEntities[o].show();
}else{
_GeoServerlayerEntities[o].hide();
}
}
}
/**
* 控制geoServer图层 显示与隐藏
* pipeCode : 管线压力级制编码
* checkType : 选中还是取消选中
*/
this.geoServerLayerVisibleOrHide = function(pipeCode, checkType){
var self = this;
var _GeoServerlayerEntities = self.GeoServerlayerEntities;
var glayer = _GeoServerlayerEntities[pipeCode];
if(checkType){
glayer.show();
}else{
glayer.hide();
}
};
this.drawPolygon = function(mPolygon){
var _self = this;
var coordinatesList = [];
if (mPolygon.points.length > 0) {
$.each(mPolygon.points, function(coordinateIndex, coordinateEntry) {
if(coordinateEntry.lng && coordinateEntry.lat && Number(coordinateEntry.lng)>0 && Number(coordinateEntry.lat)>0){
var transCoordinate = {
'lng':coordinateEntry.lng,
'lat':coordinateEntry.lat
}
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!mPolygon.noTransAmap) {
var transCoordinate = _self.get_GCJLngLat(coordinateEntry);
}
coordinatesList.push(new AMap.LngLat(transCoordinate.lng, transCoordinate.lat));
}
});
if(coordinatesList.length>0) {
polygon = new AMap.Polygon({
map:_self.map,
path: coordinatesList,//设置多边形边界路径
strokeColor: mPolygon.color?mPolygon.color:"#FF33FF", //线颜色
strokeOpacity: mPolygon.opacity?mPolygon.opacity:0.2, //线透明度
strokeWeight: mPolygon.width?mPolygon.width:3, //线宽
fillColor: mPolygon.fillColor?mPolygon.fillColor:"#1791fc", //填充色
fillOpacity: mPolygon.fillOpacity?mPolygon.fillOpacity:0.35,//填充透明度
zIndex:mPolygon.zIndex
});
}
}
return polygon;
};
this.drawLine = function(mLine){
var _self = this;
var polyLine;
var coordinatesList = [];
if (mLine.pionts.length > 0) {
$.each(mLine.pionts, function(coordinateIndex, coordinateEntry) {
if(coordinateEntry.lng && coordinateEntry.lat && Number(coordinateEntry.lng)>0 && Number(coordinateEntry.lat)>0){
var transCoordinate = {
'lng':coordinateEntry.lng,
'lat':coordinateEntry.lat
}
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!mLine.noTransAmap) {
var transCoordinate = _self.get_GCJLngLat(coordinateEntry);
}
coordinatesList.push(new AMap.LngLat(transCoordinate.lng, transCoordinate.lat));
}
});
if(coordinatesList.length>0) {
polyLine = new AMap.Polyline({
id : mLine.id,
map:_self.map,
path: coordinatesList, //设置线覆盖物路径
strokeColor: mLine.color, //线颜色
strokeOpacity: mLine.opacity, //线透明度
strokeWeight: mLine.width, //线宽
strokeStyle: mLine.style, //线样式
strokeDasharray: mLine.dasharray //补充线样式
});
}
if(mLine.infowindow && !$.isEmptyObject(mLine.infowindow)) {
if(!$('body').find('#infowindow').length>0) {
var html = '<div id="infowindow" style="position:absolute;display:none" class="box_wraper"><div class="box_con"><p></p></div><div class="box_img"><img src="/HRSmartGas/platform/images/box_img.png"/></div></div>';
$('body').append(html);
}
polyLine.on('mouseover',function(e) {
$('body').find('#infowindow p').html(mLine.infowindow.content);
$('#infowindow').show();
$('#infowindow').css("left",e.pixel.x-$('#infowindow').width()/2);
$('#infowindow').css("top",e.pixel.y-$('#infowindow').height());
});
polyLine.on('mouseout',function(e) {
$('#infowindow').hide();
});
}
if(mLine.onClick){
polyLine.on('click',function(e) {
mLine.onClick(e);
});
}
}
return polyLine;
};
/**
* 删除点
* point 为map地图对象, drawPoint时返回
*/
this.removePoint = function(point){
this.map.remove(point);
};
this.removeLine = function(mLine){
var _self = this;
_self.map.remove(mLine);
};
this.removePolygon = function(polygon){
var _self = this;
_self.map.remove(polygon);
};
this.drawPoint = function(mPoint){
debugger;
var _self = this;
var transCoordinate = {
'lng':mPoint.lng,
'lat':mPoint.lat
};
var marker;
if(mPoint.lng && mPoint.lat && Number(mPoint.lng)>0 && Number(mPoint.lat)>0){
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!mPoint.noTransAmap) {
transCoordinate = _self.get_GCJLngLat(mPoint);
}
var icon;
if(mPoint.type.imgUrl == "") {
icon = new AMap.Icon({
imageSize:new AMap.Size(mPoint.type.width,mPoint.type.height),
size: new AMap.Size(mPoint.type.width,mPoint.type.height), //图标大小
});
} else {
icon = new AMap.Icon({
imageSize:new AMap.Size(mPoint.type.width,mPoint.type.height),
size: new AMap.Size(mPoint.type.width,mPoint.type.height), //图标大小
image:mPoint.type.imgUrl
});
}
var pointOpitons = {
map:_self.map,
icon:icon,
position:[transCoordinate.lng,transCoordinate.lat],
offset:new AMap.Pixel(mPoint.type.xoffset, mPoint.type.yoffset), //偏移量
title:mPoint.type.title, //点的文字提示
extData:mPoint
};
marker = new AMap.Marker(pointOpitons);
mPoint.marker = marker;
if(mPoint.type.onClick && $.isFunction(mPoint.type.onClick)) {
marker.on('click',function(e){
debugger;
mPoint.type.onClick(e.target.getExtData(),null);
}); //点事件的获取
}
if(null != mPoint.labelContent && '' != mPoint.labelContent && 'undefined' != mPoint.labelContent){
marker.setLabel({
offset: new AMap.Pixel(20, -10), //显示位置
content: mPoint.labelContent //显示内容
});
}
_self.markers.push(mPoint);
}
if(mPoint.type.showInfo && mPoint.type.infowindow && !$.isEmptyObject(mPoint.type.infowindow)) {
debugger;
if(marker != undefined) {
var position = {
'lng':mPoint.lng,
'lat':mPoint.lat
};
if(!mapOption.noTransAmap) {
position = _self.get_GCJLngLat({'lng':mPoint.lng,'lat':mPoint.lat});
}
var infowindow = mPoint.type.infowindow;
var infoMouseOverWin = new AMap.InfoWindow({
isCustom:true,
content: infowindow.content,
offset: new AMap.Pixel(infowindow.xoffset,infowindow.yoffset)
});
infoMouseOverWin.open(_self.map, new AMap.LngLat(position.lng,position.lat));
_self.infoWindow.uniqueCode = mPoint.busiKey;
}
}
};
/**
* 展示自定义弹出框
*/
this.showInfoWindow = function(mPoint){
debugger;
var _self = this;
if(mPoint.type.infowindow && !$.isEmptyObject(mPoint.type.infowindow)) {
var position = {
'lng':mPoint.lng,
'lat':mPoint.lat
};
if(!mapOption.noTransAmap) {
position = _self.get_GCJLngLat({'lng':mPoint.lng,'lat':mPoint.lat});
}
var infowindow = mPoint.type.infowindow;
var infoMouseOverWin = new AMap.InfoWindow({
isCustom:true,
content: infowindow.content,
offset: new AMap.Pixel(infowindow.xoffset,infowindow.yoffset)
});
infoMouseOverWin.open(_self.map, new AMap.LngLat(position.lng,position.lat));
_self.infoWindow.uniqueCode = mPoint.busiKey;
}
}
this.getInfoWindowUnique = function(){
var _self = this;
return _self.infoWindow.uniqueCode;
}
this.clearGraphics = function(type) {
var _self = this;
for(var i =0; i<_self.markers.length; i++){
if(type){
if((_self.markers[i].node == type))
_self.map.remove(_self.markers[i].marker);
}else{
_self.map.remove(_self.markers[i].marker);
}
}
};
/**
* e 鼠标事件对象
*/
function getScreenPoint(e){
return new SreenPoint({x:e.pixel.x, y:e.pixel.y});
};
/**
* e 鼠标事件对象
*/
function getMapPoint(e){
return new MapPoint({'lng' : e.lnglat.lng, 'lat' : e.lnglat.lat});
};
//绘制管线图层
this.drawArcgisTile = function(url,token,callback) {
var _self = this;
if(_self.mapLayer){
mapLayer.setTileUrl(callback);
} else {
_self.mapLayer = new AMap.TileLayer({
zIndex:20,
getTileUrl: function(x,y,z){
return url+'/'+ z +'/'+ y +'/'+ x+'?token='+token;
}
});
_self.mapLayer.setMap(_self.map);
}
return _self.mapLayer;
};
//重新加载arcgis管线图层
this.reloadArcgisTile = function(){
if(_self.mapLayer && _self.map){
_self.mapLayer.setMap(_self.map);
}
}
//画热力图
this.drawHeatMap = function(heatMap) {
var _self = this;
var coordinatesList = [];
if (heatMap.data.length > 0) {
$.each(heatMap.data, function(coordinateIndex, coordinateEntry) {
if(coordinateEntry.lng && coordinateEntry.lat && Number(coordinateEntry.lng)>0 && Number(coordinateEntry.lat)>0){
var transCoordinate = {
'lng':coordinateEntry.lng,
'lat':coordinateEntry.lat
}
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!heatMap.noTransAmap) {
transCoordinate = _self.get_GCJLngLat(coordinateEntry);
}
coordinatesList.push(new AMap.LngLat(transCoordinate.lng, transCoordinate.lat));
}
});
}
if(coordinatesList.length>0) {
_self.map.plugin(["AMap.Heatmap"], function() {
//初始化heatmap对象
_self.heatmap = new AMap.Heatmap(_self.map, {
radius: 80, //给定半径
opacity: [0, 0.8]
});
//设置数据集
_self.heatmap.setDataSet({
data: coordinatesList,
max: 2
});
});
}
}
/**
*画圆 获取中心点及半径
*20180122
*/
this.draw =function (){
var _self = this;
var mouseTool = new AMap.MouseTool(_self.map);
//自定义图形样式
mouseTool.polyline({
strokeColor:"#f50", // 线条颜色,十六进制
strokeOpacity:0.5, // 线条透明度
strokeWeight:10, // 线条宽度
strokeStyle:"dashed" // 线条样式 solid || dashed
});
//在地图中添加MouseTool插件
mouseTool.circle(); //用鼠标工具画圆
AMap.event.addListener( mouseTool,'draw',function(e){ //添加事件
console.log(e.obj.getRadius());//获取半径
console.log(e.obj.getCenter());//获取中心点
showChoseDevice(e.obj.getRadius(),e.obj.getCenter());
mouseTool.close(true);//关闭当前鼠标操作
});
} ;
//画圆
this.drawCircle = function(circle){
var _self = this;
var center = new AMap.LngLat(circle.center.lng,circle.center.lat);
var circleOptions = {
center:center,
zIndex:1000,
radius:circle.radius, //半径1公里
strokeColor: "#F33", //线颜色
strokeOpacity: 1, //线透明度
strokeWeight: 3, //线粗细度
fillColor: "#ee2200", //填充颜色
fillOpacity: 0.35//填充透明度
};
var _circle = new AMap.Circle(circleOptions);
_circle.setMap(_self.map);
circle.marker = _circle;
}
this.circleContains = function(circle,point) {
var _self = this;
var transCoordinate = {
'lng':point.lng,
'lat':point.lat
}
//若不是从天地图转换为高德地图,则不用转换坐标系
if(!point.noTransAmap) {
transCoordinate = _self.get_GCJLngLat(point);
}
var _point = new AMap.LngLat(transCoordinate.lng,transCoordinate.lat);
var isContains = circle.marker.contains(_point);
return isContains;
}
//绑定地图缩放事件
this.bindZoomChange = function(callBack) {
var _self = this;
_self.map.on('zoomchange', function(e) {
callBack(_self.map.getZoom());
});
}
//绑定地图单击事件
this.bindClick = function(callBack) {
var _self = this;
_self.map.on('click', function(e) {
callBack(e.lnglat.getLng(),e.lnglat.getLat(),_self.map.getZoom());
});
}
/**
* 获取缩放等级
*/
this.getZoom = function(){
var _self = this;
return _self.map.getZoom();
}
//显示或隐藏热力图
this.showHeatMap = function(isShow) {
var _self = this;
if(_self.heatmap) {
if(isShow) {
_self.heatmap.show();
} else {
_self.heatmap.hide();
}
}
}
//添加右键菜单获取坐标
this.addGetLnglatMenu = function() {
var _self = this;
var menu = new AMap.ContextMenu();
//添加菜单项
menu.addItem("发送任务",function() {
debugger;
mapDbClick(contextMenuPositon.getLat(),contextMenuPositon.getLng());
//alert(contextMenuPositon.getLng() + "," + contextMenuPositon.getLat());
},0);
//为地图注册rightclick事件获取鼠标点击出的经纬度坐标
var clickEventListener = _self.map.on('rightclick', function(e) {
menu.open(_self.map,e.lnglat);
contextMenuPositon = e.lnglat;
});
};
this.setCenter = function(lnt,lat) {
var transCoordinate = {
'lng':lnt,
'lat':lat
};
var _self = this;
if(!mapOption.noTransAmap) {
_self.centerPoint.lng = lnt;
_self.centerPoint.lat = lat;
transCoordinate = _self.get_GCJLngLat(_self.centerPoint);
}
_self.map.setCenter(new AMap.LngLat(transCoordinate.lng, transCoordinate.lat));
};
this.closeInfoWindow = function(infoWindow) {
var _self = this;
_self.map.clearInfoWindow();
};
this.fromLngLatToContainerPixel = function(mPoint) {
var _self = this;
var retObj = _self.map.lnglatToPixel(new AMap.LngLat(mPoint.lng,mPoint.lat));
return new SreenPoint(retObj);
};
this.fromContainerPixelToLngLat = function(mPoint) {
var _self = this;
var retObj = _self.map.pixelToLngLat(new AMap.Pixel(mPoint.x,mPoint.y));
return new MapPoint(retObj);
};
this.setFitView = function() {
var _self = this;
_self.map.setFitView();
};
this.zoomOut = function() {
var _self = this;
_self.map.zoomOut();
}
this.get_GCJLngLat = function(mPoint) {
var retObj = {};
var CT = new CoordinateTransform(mPoint.lat, mPoint.lng, CoordinateSys.WGS84);//CoordinateSys.WGS84 是转换前的坐标系
var retValue = new Object();
if (CT.WGS84ToGCJ02()== false)//WGS84ToBD09()方法 WGS84转BD坐标,如果是转成火星坐标改调用WGS84ToGCJ02()
console.info(CT.get_ErrMsg());
retObj.lat = CT.get_GCJLat() == 0 ? mPoint.lat : CT.get_GCJLat();//获取转换后的高德坐标纬度
retObj.lng = CT.get_GCJLng() == 0 ? mPoint.lng : CT.get_GCJLng();//获取转换后的高德坐标精度
return retObj;
};
};
function openWindowTask(tltle,url){
var options = {
modal : true,
title : tltle,
collapsible : false,
minimizable : false,
maximizable : false,
closable : true,
closed : false
};
var uid = "self_card_";
options["id"] = uid;
winFormDesigner = UIFactory.getUI(uid);
if(!winFormDesigner){
winFormDesigner = UIFactory.create(xpad.ui.Window, options);
}
var root = jQuery("body");
var offset = root.offset();
var winleft = 0;
var wintop = 0;
var newSize = {};
newSize["left"] = (jQuery("body").width()-450)/2;
newSize["top"] = 20;
newSize["width"] = 450;//jQuery("body").width();
newSize["height"] = 500;//jQuery("body").height();
winFormDesigner.window("resize", newSize);
setTimeout(function(){
winFormDesigner.loadURL(url);
}, 0);
}
AutoNaviMap.CLASS_NAME = "AutoNaviMap";
/**高德autonavi 地图API Define:end */
上一篇: 高德地图界面开发
下一篇: 谷歌地图开发--- 地图显示
推荐阅读
-
贪婪算法在 Python、JavaScript、Java、C++ 和 C# 中的多种实现及其在硬币变化、分数骑士、活动选择和使用哈夫曼编码的最小生成树问题中的应用实例
-
中兴通讯:中兴宏梦研究院专注于金融领域应用技术和产品的研究、开发和营销。
-
脚本开发和自动运行 ----shell 脚本开发及其在 DevOps 中的应用!
-
为开发人员和设计师推荐的 iPad 应用程序
-
NeurIPS 2022 | 最强斗地主AI!网易互娱AI Lab提出基于完美信息蒸馏的方法-完美信息蒸馏(PTIE) 在斗地主游戏中,非完美信息的引入主要是由于三位玩家均不能看到别人的手牌,对于任意一位玩家而言,仅可知道其余两位玩家当前手牌的并集,而难于精准判断每位玩家当前手牌。完美信息蒸馏的思路是针对这种非完美问题,构建一个第三方角色,该角色可以看到三位玩家的手牌,该角色在不告知每位玩家完美信息的情况下通过信息蒸馏的方式引导玩家打出当前情况下合理的出牌。 以强化学习常用的 Actor-Critic 算法为例,PTIE 在 Actor-Critic 算法的应用中可以利用 Critic 的 Value 输出作为蒸馏手段来提升 Actor 的表现。具体而言即在训练中 Critic 的输入为完美信息(包含所有玩家的手牌信息),Actor 的输入为非完美信息(仅包含自己手牌信息),此种情况下 Critic 给予的 Value 值包含了完美信息,可以更好地帮助 Actor 学习到更好的策略。 从更新公式上来看,正常的 Actor-Critic 算法 Actor 更新的方式如下: 在 PTIE 模式下,对于每个非完美信息状态 h,我们可以在 Critic 中构建对应的完美信息状态 D(h),并用 Critic 的输出来更新 Actor 的策略梯度,从而达到完美信息蒸馏的效果。 PTIE 框架的整体结构如下图所示: 无论是训练还是执行过程中智能体都不会直接使用完美信息,在训练中通过蒸馏将完美信息用于提升策略,从而帮助智能体达到一个更高的强度。 PTIE 的另一种蒸馏方式是将完美信息奖励引入到奖励值函数的训练中,PerfectDou 提出了基于阵营设计的完美信息奖励 node reward,以引导智能体学习到斗地主游戏中的合作策略,其定义如下: 如上所示,完美信息部分 代表 t 时刻地主手牌最少几步可以出完,在斗地主游戏中可以近似理解为是距游戏获胜的距离, 代表 t 时刻地主阵营和农民阵营距游戏获胜的距离之差, 为调节系数。通过此种奖励设计,在训练时既可以一定程度地引入各玩家的手牌信息(出完的步数需要知道具体手牌才能计算),同时也鼓励农民以阵营的角度做出决策,提升农民的合作性。 特征构建: PerfectDou 针对牌类游戏的特点主要构建了两部分特征:牌局状态特征和动作特征。其中牌局状态特征主要包括当前玩家手牌牌型特征、当前玩家打出的卡牌牌型特征、玩家角色、玩家手牌数目等常用特征,动作特征主要用于刻画当前状态下玩家的所有可能出牌,包括了每种出牌动作的牌型特征、动作的卡牌数目、是否为最大动作等特征。 牌型特征为 12 * 15 的矩阵,如下图所示: 该矩阵前 4 行代表对应每种卡牌的张数,5-12 行代表该种卡牌的种类和对应位置。 网络结构和动作空间设计 针对斗地主游戏出牌组合数较多的问题,PerfectDou 基于 RLCard 的工作上对动作空间进行了简化,对占比最大的两个出牌牌型:飞机带翅膀和四带二进行了动作压缩,将整体动作空间由 27472 种缩减到 621 种。 PerfectDou 策略网络结构如下图所示: 策略网络结构同样分为两部分:状态特征部分和动作特征部分。 在状态特征部分,LSTM 网络用于提取玩家的历史行为特征,当前牌局状态特征和提取后的行为特征会再通过多层的 MLP 网络输出当前的状态信息 embedding。 在动作特征部分,每个可行动作同样会经过多层 MLP 网络进行编码,编码后的动作特征会与其对应的状态信息 embedding 经过一层 MLP 网络计算两者间的相似度,并经由 softmax 函数输出对应的动作概率。 实验结果
-
什么是可用性测试?有效性(Effectiveness)-- 用户完成特定任务和实现特定目标的正确性和完整性程度;效率(Efficiency)-- 用户完成任务的正确性和完整性程度与所用资源(如时间)之比;满意度(Satisfaction)-- 用户在使用产品时的主观满意度和接受程度。 2.如何获得可用性? 可以参考以下原则:Gould、Boies 和 Lewis(1991 年)为以用户为中心的设计定义了 4 个重要原则: 早期以用户为中心:设计者应在设计过程的早期就努力了解用户的需求。 综合设计:设计的所有方面都应同步发展,而不是按顺序进行。使产品的内部设计始终与用户界面的需求保持一致。 早期和持续测试:当今唯一可行的软件测试方法是经验主义方法,即如果实际用户认为设计可行,该设计就是可行的。通过在整个开发过程中引入可用性测试,用户就有机会在产品推出之前对设计提出反馈意见。 迭代设计:大问题往往掩盖了小问题的存在。设计人员和开发人员应在整个测试过程中对设计进行迭代。 3...什么是可用性测试? 可用性测试是根据可用性标准对图形用户界面进行的系统评估。 可用性测试是衡量用户与系统(网站、软件应用程序、移动技术或任何用户操作设备)交互时的体验质量。4.如何进行可用性测试? l 实验室实验
-
基于 NFC 的无线电池管理 BMS - ● 主动读取内部传感器:利用 NFC 技术,BMS 能够主动读取内部传感器的数据 [... 考虑车辆外使用案例中的空闲状态场景:NFC 技术可用于处理闲置状态下的电池组读取,例如在第二次生命转移期间进行存储。 主动诊断读取:在邻近系统中部署了 BMS 的情况下,使用 NFC 技术进行主动诊断读取。 (ii) 系统结构 系统架构如图所示,在建立安全通道之前,需要对设备进行身份验证。数据链路通信层由 NDEF 记录处理,而数据存储可以是离线的,也可以是数据库中的在线存储。活动和空闲状态的诊断读数取决于设备和数据方向,需要与外部 NFC 阅读器进行通信。软件架构分为三层,包括硬件抽象层(HAL)、中间层(中间件)和应用层。HAL 处理硬件驱动组件,中间件执行设备验证,而应用层则由开发人员根据安全漏洞和格式扩展*定义。 为确保安全,系统采用了一个安全模型,为 BMS 和主动诊断读取情况格式化应用数据。安全考虑因素包括设备相互验证、使用安全通道(加密和防篡改)以及确保电池组内读数的安全。 考虑到不同的 BMS 拓扑,包括集中式、调制式、分布式和分散式,系统需要满足设备相互验证和使用安全通道的要求。对于每种拓扑结构,都必须考虑将性能开销降至最低。电池是封闭的,对其进行物理攻击不可行或成本太高。外部攻击可能也很困难。基于对称或非对称加密技术的自动验证可用于保护电池组读数。安全协议在验证阶段和会话密钥确认阶段采用双密钥加密,以抵御攻击。中间件在数据格式验证、确认和处理中发挥关键作用,确保数据传输安全。 (iii) 唤醒模型设计
-
流应用程序接口(Stream API)提供了许多处理和转换数据流的操作。
-
介绍使用 PHP 开发内容管理系统的优势和高效应用技术分析
-
软考中级(网络工程师考核要点) 第 1 章 计算机网络系统(信道特性的应用) 第 6 期(4B/5B 编码、数字调制技术和脉冲编码调制)