|
var toggleFacFilter = "";
|
|
var TPCFeatureInfoCtrl=function (config,funProcFeautres)//(popupFrm,commands){ //ctlMouseOver,ctlClick,ctlDblClick){
|
{
|
this.checkVal = toggleFacFilter;
|
|
this.setProcFeautres=function(funcProc)
|
{
|
funProcFeautres=funcProc;
|
}
|
var ctl= new OpenLayers.Control.WMSGetFeatureInfo({
|
// url: 'http://www.ximple.com.tw:80/geoserver/xtpc/wms',
|
maxFeatures:OpenLayers.WMSFEATURECOUNT,
|
title: 'Identify features by clicking',
|
projection:config.projection,
|
layers: [],
|
drillDown:false,
|
eventListeners: {
|
beforegetfeatureinfo: function(evt) {
|
/*
|
this.vendorParams['cql_filter']=this.layers[0].params.CQL_FILTER;
|
if(config.filterDgn==true)
|
{
|
|
var qTemp=config.map.getLonLatFromPixel(evt.xy);
|
qTemp = qTemp.transform(config.map.projection, tw97);
|
|
var dgnid=dgnParser.get1000(qTemp.lon,qTemp.lat);
|
//config.map.projection 3857
|
if(typeof(this.vendorParams['cql_filter'])=='undefined')
|
{
|
this.vendorParams['cql_filter']='DGNID='+dgnid;
|
}
|
else
|
{
|
this.vendorParams['cql_filter']=this.vendorParams['cql_filter']+ 'AND DGNID='+dgnid;
|
}
|
if (this.checkVal.length > 0)
|
{
|
this.vendorParams['cql_filter'] = this.vendorParams['cql_filter'] + ' AND ' + this.checkVal;
|
|
}
|
|
}*/
|
if(typeof(this.vendorParams['cql_filter'])=='undefined')
|
{
|
delete this.vendorParams.cql_filter;
|
}
|
},
|
getfeatureinfo: function(event) {
|
|
//console.log(event);
|
//var items = [];
|
/*
|
var result={};
|
for(var idx=0;idx<event.features.length;idx++)
|
{
|
var aFeature=event.features[idx];
|
var aFeatureKey=aFeature.attributes.tid+'-'+aFeature.attributes.did+'-'+aFeature.attributes.oid;
|
if(result.hasOwnProperty(aFeatureKey))
|
{
|
if(aFeature.attributes.cid=='0')
|
{
|
result[aFeatureKey]=aFeature;
|
}
|
}
|
else
|
{
|
result[aFeatureKey]=aFeature;
|
}
|
}
|
//debugger;
|
var distinct=[];
|
for(var aFeatureKey in result)
|
{
|
distinct.push(result[aFeatureKey]) ;
|
}
|
*/
|
//debugger;
|
if(funProcFeautres)funProcFeautres({event:event});
|
}
|
},
|
queryVisible: true});
|
|
ctl.infoFormat = 'application/vnd.ogc.gml';
|
//if(callbackFun!=null)
|
// ctl.events.register("getfeatureinfo", this, callbackFun);
|
return ctl;
|
|
} ;
|
|
|
function DrawControl(initLayer,config)
|
{
|
if(typeof(config)=='undefined')config={};
|
|
var controlmap=config.map;
|
var vectorLayer=initLayer;
|
|
var reportEvent;
|
if (window.console && window.console.log) {
|
reportEvent = function(event) {
|
//debugger;
|
console.log(event.type,
|
event.feature ? event.feature.id : event.components);
|
};
|
} else {
|
reportEvent = function() {
|
};
|
}
|
|
|
|
this.setToggleFac=function(cnd){
|
toggleFacFilter = cnd;
|
}
|
|
var drawControls = {
|
pan: new OpenLayers.Control.Pan(),
|
// zoombox:new OpenLayers.Control.ZoomBox(),
|
// zoomin:new OpenLayers.Control.ZoomIn(),
|
// zoomout:new OpenLayers.Control.ZoomOut(),
|
point: new OpenLayers.Control.DrawFeature(vectorLayer,
|
OpenLayers.Handler.Point),
|
// multiPoint: new OpenLayers.Control.DrawFeature(vectorLayer,
|
// OpenLayers.Handler.Point, {handlerOptions: {multi: true}}),
|
line: new OpenLayers.Control.DrawFeature(vectorLayer,
|
OpenLayers.Handler.Path),
|
polygon: new OpenLayers.Control.DrawFeature(vectorLayer,
|
OpenLayers.Handler.Polygon
|
),
|
modify: new OpenLayers.Control.ModifyFeature(vectorLayer, {
|
deferDelete: true,
|
eventListeners: {
|
'beforefeaturedeleted': reportEvent,
|
'featuredeleted': reportEvent
|
},
|
tools: [ // custom tools
|
{
|
// to rotate the "angle" attribute of a ponit by steps of 15 degrees
|
geometryTypes: ['OpenLayers.Geometry.Point',
|
'OpenLayers.Geometry.MultiPoint'],
|
dragAction: function(feature, initialAtt, escale, rotation) {
|
var angle = ((initialAtt.angle || 0) - rotation) % 360;
|
// force steps of 15 degrres
|
angle = Math.floor(angle / 15) * 15;
|
feature.attributes.angle = angle;
|
},
|
style: OpenLayers.Control.ModifyFeature_styles.rotate
|
}, {
|
// to resize the pointRadius.
|
geometryTypes: ['OpenLayers.Geometry.Point',
|
'OpenLayers.Geometry.MultiPoint'],
|
dragAction: function(feature, initialAtt, escale, rotation) {
|
var radius = (initialAtt.radius || 6) * escale;
|
feature.attributes.radius = Math.max(6, radius);
|
},
|
style: OpenLayers.Control.ModifyFeature_styles.resize
|
}, {
|
// to close a lineString as a ring
|
geometryTypes: ['OpenLayers.Geometry.LineString'],
|
pressingAction: function(feature) {
|
var geometry = feature.geometry;
|
geometry.addComponent(geometry.components[0].clone());
|
},
|
style: {
|
label:'ring',
|
title: 'press to close as a ring',
|
cursor: "pointer",
|
fontSize: '8px',
|
fontColor: '#222',
|
pointRadius: 10,
|
fillColor: '#cccccc',
|
strokeColor: '#444444'
|
}
|
}]
|
})
|
|
};
|
drawControls.modify.mode |= OpenLayers.Control.ModifyFeature.VERTICES;
|
drawControls.modify.mode |= OpenLayers.Control.ModifyFeature.ROTATE;
|
drawControls.modify.mode |= OpenLayers.Control.ModifyFeature.RESIZE;
|
//drawControls.modify.mode |= OpenLayers.Control.ModifyFeature.DEFORM;
|
drawControls.modify.mode |= OpenLayers.Control.ModifyFeature.DRAG;
|
drawControls.modify.mode |= OpenLayers.Control.ModifyFeature.DELETE;
|
//drawControls.modify.mode |= OpenLayers.Control.ModifyFeature.RESHAPE;
|
//addfunction
|
//drawControls["tpcquery"]= TPCFeatureInfoCtrl({"projection":"EPSG:3826"},function(){});
|
DrawControl.prototype.addControl=function(name,ctl)
|
{
|
drawControls[name]=ctl;
|
}
|
|
DrawControl.prototype.getDrawControls=function(){ return drawControls;}
|
|
|
|
|
|
//var toolbarPanel=new OpenLayers.Control.NavToolbar();
|
var toolbarPanel=[];
|
// maketools
|
|
function toggleControl(apiName,callbackFunc,func_type) {
|
|
for (key in drawControls) {
|
var aCtl = drawControls[key];
|
aCtl.setMap(controlmap); //this==panel
|
if (apiName === key ) {//&& element.checked
|
|
|
var aCtldeactivate=function(evt)
|
{
|
if(typeof(callbackFunc)!='undefined')
|
{
|
|
callbackFunc(evt);
|
|
//halt ,marked=forever
|
//toggleControl('pan');
|
|
//drawControls[key].events.unregister('featureadded', drawControls[key],this);
|
|
|
}
|
}
|
if(drawControls[key].events.listeners.hasOwnProperty('featureadded'))
|
{
|
drawControls[key].events.listeners['featureadded'].splice(0,1);
|
/*
|
var listeners = drawControls[key].events.listeners['featureadded'];
|
for (var idxOfEvent=0; idxOfEvent<listeners.length; idxOfEvent++)
|
{
|
if(listeners[idxOfEvent].obj==drawControls[key]
|
&& listeners[idxOfEvent].func==aCtldeactivate)
|
{
|
listeners.splice(idxOfEvent, 1);
|
break;
|
}
|
|
}
|
*/
|
}
|
if(func_type||'draw'=='draw')
|
{
|
drawControls[key].events.register('featureadded', drawControls[key],aCtldeactivate);
|
}
|
|
if (apiName == "facquery") {
|
aCtl.checkVal = toggleFacFilter;
|
}
|
|
|
aCtl.activate();
|
} else {
|
aCtl.deactivate();
|
}
|
}
|
}
|
DrawControl.prototype.toggle=function(apiName,recallFunc)
|
{
|
toggleControl(apiName,recallFunc);
|
}
|
/*
|
DrawControl.prototype.query=function(apiName,recallFunc)
|
{
|
toggleControl(apiName||'facQuery',recallFunc,'query');
|
}*/
|
var extToolbar = [];
|
var btnsubmenu4 = [];
|
DrawControl.prototype.addExtToolButton = function (name, config, handler) {
|
var btn = // new OpenLayers.Control.Button({
|
({
|
text: name,
|
tooltip: config.name,
|
/*{
|
text: name
|
},*/
|
id: config.eventId || name + " ",
|
//trigger: handler||function(a){
|
// console.log('newBtnClick');
|
config: config || {},
|
handler: handler || function (a) {
|
// console.log('default-'+eventId);
|
toggleControl(config.eventId);
|
}
|
// ,type: OpenLayers.Control.TYPE_BUTTON
|
});
|
|
delete btn.iconCls;
|
btn.text = btn.tooltip;
|
btn.width = 120;
|
btn.height = 24;
|
|
if (config.menu == "submenu4") {
|
if (btnsubmenu4 == "") {
|
btnsubmenu4 = {
|
text: 'OA定位',
|
tooltip: 'OA定位',
|
width: 50,
|
height: 40,
|
iconCls: 'tblocate',
|
menu: [], handler: function (a) { }
|
}
|
}
|
delete btn.iconCls;
|
btn.text = btn.tooltip;
|
btn.width = 120;
|
btn.height = 24;
|
btnsubmenu4.menu.push(btn);
|
}
|
return btn;
|
}
|
|
DrawControl.prototype.getExtToolbar=function()
|
{
|
var extToolbar = [];
|
var btnsubmenu3 = {
|
|
text: '設備定位',
|
tooltip: '設備定位',
|
width: 50,
|
height: 40,
|
iconCls: 'tblocate',
|
menu: [], handler: function (a) { }
|
|
}
|
var btnsubmenu2 = {
|
|
text: '查詢',
|
tooltip: '查詢',
|
width: 50,
|
height: 40,
|
iconCls: 'tbquery',
|
menu: [], handler: function (a) { }
|
|
}
|
var btnsubmenu1 = {
|
|
text: '基本定位',
|
tooltip: '基本定位',
|
width: 50,
|
height: 40,
|
iconCls: 'tblocate',
|
menu: [], handler: function (a) { }
|
|
}
|
|
var btn = dwc1.addExtToolButton('道路定位', { eventId: 'locRoad', name: '道路定位' }, function () {
|
Ext.getCmp("InputLocateRoad").show();
|
});
|
btnsubmenu1.menu.push(btn);
|
|
btn = dwc1.addExtToolButton('門牌定位', { eventId: 'locAddr', name: '門牌定位' }, function (sender) {
|
dwc1['qf']({ group: "ADDRESS0", name: "q", displayname: "", column: [] },
|
{
|
qconfig: { catelog: 'address' },
|
querybyDgnUfid: false, SelectLayout: 'onlyResult'
|
});
|
});
|
btnsubmenu1.menu.push(btn);
|
|
btn = dwc1.addExtToolButton('重要地標定位', { eventId: 'locLMark', name: '重要地標定位' }, function (sender) {
|
dwc1['qf']({
|
group: "LANDMARK.0", name: "q", displayname: "查詢", column: [
|
{ "cname": "名稱", "ctype": "str", "require": false, "code": [] }
|
]
|
},
|
{
|
qconfig: { catelog: 'theme' },
|
querybyDgnUfid: false, SelectLayout: 'onlyResult'
|
});
|
});
|
btnsubmenu1.menu.push(btn);
|
|
btn = dwc1.addExtToolButton('圖號定位', { eventId: 'locGraph', name: '圖號定位' }, function () {
|
Ext.getCmp("InputLocateMapNo").show();
|
});
|
btnsubmenu1.menu.push(btn);
|
|
btn = dwc1.addExtToolButton('座標定位', { eventId: 'locCor', name: '座標定位' }, function () {
|
Ext.getCmp("InputLocateXY").show();
|
});
|
btnsubmenu1.menu.push(btn);
|
|
btn = dwc1.addExtToolButton('分處定位', { eventId: 'locDiv', name: '分處定位' }, function (sender) {
|
Ext.getCmp("InputSubdivisionLocate").show();
|
|
dwc1['qf']({ group: "DEPT", name: "q", displayname: "", column: [] },
|
{
|
qconfig: { catelog: 'theme' },
|
querybyDgnUfid: false, SelectLayout: 'onlyResult'
|
});
|
});
|
btnsubmenu1.menu.push(btn);
|
|
btn = dwc1.addExtToolButton('座標查詢', { eventId: 'qryCor', name: '座標查詢' }, function () { QueryXY(); });
|
btnsubmenu2.menu.push(btn);
|
btn = dwc1.addExtToolButton('圖號查詢', { eventId: 'QryGraph', name: '圖號查詢' }, function () { QueryMapNO(); });
|
btnsubmenu2.menu.push(btn);
|
|
|
extToolbar.push(btnsubmenu1);
|
extToolbar.push(btnsubmenu2);
|
|
var queryHandler = new twdQueryInfo();//["HYDRANT", "VALVE", "METER", "DRINK", "STATION"]
|
|
var idxOfQH;
|
|
for (idxOfQH = 0; idxOfQH < queryHandler.getSchema().length; idxOfQH++) {
|
|
if (typeof (queryHandler.getSchema()[idxOfQH].group) == "undefined") continue;
|
if (typeof (queryHandler.getSchema()[idxOfQH].name) == "undefined") continue;
|
|
btn = dwc1.addExtToolButton(
|
queryHandler.getSchema()[idxOfQH].group + queryHandler.getSchema()[idxOfQH].name,
|
{
|
iconCls: queryHandler.getSchema()[idxOfQH].group,
|
queryinfo: queryHandler.getSchema()[idxOfQH],
|
name: queryHandler.getSchema()[idxOfQH].displayname
|
}, function (sender) {
|
//{group: "HYDRANT", name: "q", displayname: "消防栓", column: Array[2]}
|
//sender.config.queryinfo
|
dwc1['qf'](sender.config.queryinfo);
|
}
|
);
|
|
btnsubmenu3.menu.push(btn);
|
|
}//end if
|
|
extToolbar.push(btnsubmenu3);
|
|
extToolbar.push(btnsubmenu4);
|
|
return extToolbar;
|
}
|
|
DrawControl.prototype.buildExtToolBar=function()
|
{
|
var tbl1 = this.getExtToolbar();
|
var extToolpanel1 = Ext.create('Ext.window.Window', {
|
//width:420,height:75,
|
title: "圖台工具列",
|
id: "CIESBaseFunctionFrom",
|
closable: false,
|
floating: true,
|
height: 200, width: 80,
|
headerPosition: 'left',
|
layout: 'fit',
|
//items:[{xtype:'button',text:'test'},{xtype:'button',text:'test'},{xtype:'button',text:'test'} ],
|
//bbar:tbl1,
|
dockedItems: [
|
{
|
xtype: 'toolbar', dock: 'left', height: '38px',
|
items: tbl1
|
}
|
]
|
});
|
|
extToolpanel1.showAt(50,250);
|
|
return extToolpanel1;
|
}
|
|
|
//toolbarPanel.addControls([btnDrawPoint,btnDrawLine,btnDrawPolygon,btnModify]);
|
DrawControl.prototype.addToolBarButton=function(name,eventId)
|
{
|
// new OpenLayers.Control.Button(
|
var btn= {
|
title: name,
|
id: eventId
|
/*,
|
trigger: handler||function(a){
|
toggleControl(eventId);
|
}*/
|
// type: OpenLayers.Control.TYPE_BUTTON
|
};
|
toolbarPanel.push(btn);
|
//toolbarPanel.addControls([btn]);
|
|
//this.getToolbar=function(map){
|
//toolbarPanel.setMap(map);
|
//return toolbarPanel;
|
}
|
|
/* for example
|
this.addToolBarButton("導覽","pan");
|
this.addToolBarButton("畫點","point");
|
this.addToolBarButton("畫線","line");
|
this.addToolBarButton("畫面","polygon");
|
this.addToolBarButton("修改","modify");
|
*/
|
DrawControl.prototype.buildTbl=function(tblid,option)
|
{
|
//option.id= mapControl_name
|
option=option||{};
|
var elmTbl=document.getElementById(tblid);
|
if(typeof(elmTbl)=="undefined")return;
|
if(typeof (option.ctlName)=='undefined') return;
|
elmTbl.setAttribute("style","z-index:1000");
|
elmTbl.classList.add("oltoolbar");
|
|
var aBtn0=document.createElement("ul");
|
|
|
for(var idx=0;idx<toolbarPanel.length;idx++)
|
{
|
|
var aBtn1= document.createElement("li");
|
var aBtn2=document.createElement("a");
|
aBtn2.innerHTML=toolbarPanel[idx].title;
|
//aBtn.setAttribute("type","button");
|
aBtn2.setAttribute("id",toolbarPanel[idx].id);
|
aBtn2.setAttribute("href","#");
|
aBtn2.setAttribute("onclick",""+option.ctlName+".toggle('"+toolbarPanel[idx].id+"');");// toolbarPanel[idx].trigger||function(){});
|
//aBtn2.setAttribute("name",toolbarPanel[idx].title||' ');
|
aBtn2.setAttribute("title",toolbarPanel[idx].title||' ');
|
//aBtn.setAttribute("btn",toolbarPanel[idx].trigger||function(){});
|
aBtn1.classList.add("oltoolbaritem");
|
aBtn1.appendChild(aBtn2);
|
aBtn0.appendChild(aBtn1);
|
/*
|
|
title: name,
|
id: eventId,
|
trigger:*/
|
|
}
|
elmTbl.appendChild(aBtn0);
|
}
|
|
DrawControl.prototype.getMap=function(){
|
return controlmap;
|
}
|
var ctlLocate=new CtlLocate(controlmap);
|
|
DrawControl.prototype.locationTo= function(config)
|
{
|
if(typeof(config.drawAs)=="undefined")
|
{config["drawAs"]='point';}
|
if(typeof(config.zoomToCenter)=="undefined")
|
{config["zoomToCenter"]=true;}
|
|
ctlLocate.action(config);
|
}
|
|
DrawControl.prototype.clearMark= function(config)
|
{
|
ctlLocate.cancel(config);
|
}
|
|
var ctlGetWKT;
|
ctlGetWKT=new CtlGetWKT(controlmap);
|
DrawControl.prototype.getWkt= function(config)
|
{
|
return ctlGetWKT.action(config);
|
}
|
DrawControl.prototype.clearDraw= function(config)
|
{
|
ctlGetWKT.cancel();
|
}
|
|
|
var ctlCopyFeatures= new CtlCopyFeatures(initLayer);
|
//
|
var featureSelect={mode:"view",resetMode:"view"};
|
//,deleteSrc:false,clearAll:false,funclick:function(attr){}};
|
DrawControl.prototype.setSelection= function(config)
|
{
|
if(typeof(config)=='undefined')config={};
|
featureSelect.mode=config.mode||'view';
|
featureSelect.resetMode=config.resetmode||'view';
|
featureSelect.deleteSrc=config.deleteSrc||false;
|
featureSelect.clearAll=config.clearAll||false;
|
//featureSelect.srcLayer=config.srcLayer||'markup';
|
//featureSelect.desLayer=config.desLayer||'drawTemp';
|
featureSelect.funclick=config.funclick||function(mode,attr){};
|
}
|
|
function onFeatureSelect(feature) {
|
|
if(featureSelect.mode=="edit")
|
{
|
ctlCopyFeatures.action({features:[feature],clearAll:featureSelect.clearAll});
|
if(typeof(featureSelect.funclick)!="undefined")
|
featureSelect.funclick(featureSelect.mode,feature.attributes);
|
|
if(featureSelect.deleteSrc)
|
{
|
feature.destroy();
|
}
|
featureSelect.funclick=function(mode,evt){};
|
}
|
else
|
{
|
if(typeof(featureSelect.funclick)!="undefined")
|
featureSelect.funclick(featureSelect.mode,feature.attributes);
|
}
|
|
featureSelect.mode=featureSelect.resetMode;
|
|
/*
|
//selectedFeature = feature;
|
if(handlePopup){
|
e.feature.layer.map.removePopup(handlePopup);
|
handlePopup.destroy();
|
handlePopup = null;
|
}
|
handlePopup=new OpenLayers.Popup.FramedCloud(
|
"chicken",
|
feature.geometry.getBounds().getCenterLonLat(),
|
null,
|
feature.attributes.descript+'<br />'+'<a href="#" onclick="...">修改</a>',
|
null,
|
true
|
);
|
feature.layer.map.addPopup(handlePopup);
|
*/
|
}
|
|
function onFeatureUnselect(feature) {
|
//map.removePopup(feature.popup);
|
//feature.popup.destroy();
|
//feature.popup = null;
|
|
}
|
|
|
DrawControl.prototype.Events= {
|
onFeatureSelect:onFeatureSelect,
|
onFeatureUnselect:onFeatureUnselect
|
//featureQuery:facQueryHandle
|
}
|
|
};
|
|
|
|
var CtlWriteLog=function(dataList,notifyEvent) {
|
|
var notiftChanges=function()
|
{
|
if(notifyEvent!=null)
|
notifyEvent.action(dataList);
|
}
|
this.action=function(data,wkttext)
|
{
|
dataList.push(wkttext);
|
notiftChanges();
|
};
|
this.cancel=function()
|
{
|
dataList=[];
|
notiftChanges();
|
|
};
|
|
};
|