//var map;
|
var selectedFeature;
|
var offlineRest=true;
|
Proj4js.Proj["CRS:84"]=Proj4js["EPSG:4326"];
|
Proj4js.Proj["CRS:84"];
|
|
/* epsg variables */
|
//var epsg900913 = new OpenLayers.Projection("EPSG:900913");
|
var epsg3857= new OpenLayers.Projection("EPSG:3857");
|
var wgs84 = new OpenLayers.Projection("EPSG:4326");
|
var crs84 = new OpenLayers.Projection("EPSG:4326");
|
crs84.proj.srsCode="CRS:84";
|
crs84.proj.srsCodeInput="CRS:84";
|
crs84.projCode="CRS:84";
|
crs84.swapXY=true;
|
|
var tw97 = new OpenLayers.Projection("EPSG:3826");
|
var tw67 = new OpenLayers.Projection("EPSG:3828");
|
//OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.SphericalMercator.projectForward);
|
//OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:4326", OpenLayers.Layer.SphericalMercator.projectInverse);
|
|
|
Proj4js.reportError = function (msg) {
|
alert(msg);
|
}
|
//IE halt @ OpenLayers.Renderer.VML.LABEL_SHIFT.e undefined
|
//OpenLayers.Renderer.VML.LABEL_SHIFT.e=1;//Doesn't know
|
var epsgws84_bounds=new OpenLayers.Bounds(117.0305,21.6294,125.7583,26.6151) ;
|
var bounds = new OpenLayers.Bounds(116.517197643768,20.6442266131947,124.718539835259,26.4492775120834);
|
var epsg3857_bounds = new OpenLayers.Bounds(116.517197643768,20.6442266131947,124.718539835259,26.4492775120834);
|
var geojson_format = new OpenLayers.Format.GeoJSON({
|
'internalProjection': epsg3857, //wgs84,
|
'externalProjection': wgs84
|
});
|
|
|
var featurecollection={"type":"FeatureCollection","features":[]};
|
//var ajaxJson= new AjaxJson();
|
var gJsonParser= new GJSonParser();
|
|
OpenLayers.Projection.transform = function(point, source, dest) {
|
if (source && dest) {
|
|
if (!(source instanceof OpenLayers.Projection)) {
|
//console.log('new src');
|
source = new OpenLayers.Projection(source);
|
}
|
if (!(dest instanceof OpenLayers.Projection)) {
|
//console.log('new des');
|
dest = new OpenLayers.Projection(dest);
|
}
|
// debugger;
|
if (source.proj && dest.proj) {
|
//console.log(source.proj,'-->', dest.proj);
|
point = Proj4js.transform(source.proj, dest.proj, point);
|
} else {
|
|
var sourceCode = source.getCode();
|
var destCode = dest.getCode();
|
var transforms = OpenLayers.Projection.transforms;
|
if (transforms[sourceCode] && transforms[sourceCode][destCode]) {
|
transforms[sourceCode][destCode](point);
|
}
|
}
|
}
|
return point;
|
};
|
|
|
|
|
function onPopupClose(evt) {
|
selectControl.unselect(selectedFeature);
|
}
|
|
//var handlePopup;
|
function onFeatureSelect(feature) {
|
|
/*
|
//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;
|
|
}
|
//not use
|
|
//not use^
|
|
|
function onFeatureOver(e)
|
{e.feature.renderIntent = "select"; e.feature.layer.drawFeature(e.feature);
|
}
|
|
function onFeatureOut(e)
|
{ e.feature.renderIntent = "default"; e.feature.layer.drawFeature(e.feature);}
|
|
var cqlformat = new OpenLayers.Format.CQL();
|
|
var setCQL=function(layer,cql){
|
if(cql!=null)
|
if(cql.length>3500)
|
{
|
alert('資料過多,如無法正常顯示,請減少資料量') ;
|
}
|
//var nq=cqlformat.read(cql);
|
delete layer.params.CQL_FILTER;
|
layer.mergeNewParams({'CQL_FILTER':cql});
|
//layer.redraw();
|
//debugger;
|
//layer.params.CQL_FILTER=nq;
|
// console.log(cql);
|
};
|
var setAVALUES=function(layer,cql){
|
if(cql!=null)
|
if(cql.length>3500)
|
{
|
alert('資料過多,如無法正常顯示,請減少資料量') ;
|
}
|
//var nq=cqlformat.read(cql);
|
delete layer.params.AVALUES;
|
layer.mergeNewParams({'AVALUES':'1=0;'+cql+',2=2;'+cql});
|
//layer.redraw();
|
//debugger;
|
//layer.params.CQL_FILTER=nq;
|
// console.log(cql);
|
};
|
function init(maptag,config) {
|
|
var styleHighLight = new OpenLayers.Style(
|
{
|
"strokeWidth": 3, "labelOutlineColor": "#FFCCCC",
|
"labelOutlineWidth": 5 ,
|
"pointRadius": 8, "fillColor": "#006666",
|
"fillOpacity": 0.6, "strokeColor": "#006060",
|
|
"labelYOffset": -15,
|
"fontSize": "12px",
|
"pointerEvents": "visiblePainted",
|
"label": "${descript}",
|
"labelAlign": "left"
|
|
// "label" : '${key}'
|
});
|
var styleHighLightYellow = new OpenLayers.Style(
|
{
|
"strokeWidth": 3,
|
"pointRadius": 8, "fillColor": "#B0B0B0",
|
"fillOpacity": 0.6, "strokeColor": "#A0A0A0"
|
});
|
//styles
|
var styleJustGreen = new OpenLayers.Style(
|
{
|
"strokeWidth": 1,
|
"pointRadius": 6, "fillColor": "#006600",
|
"fillOpacity": 1, "strokeColor": "#303030"
|
|
//"label" : '${location}',
|
});
|
var styleYellow = new OpenLayers.Style(
|
{
|
"strokeWidth": 1,
|
"pointRadius": 6, "fillColor": "#DDDD00",
|
"fillOpacity": 0.5, "strokeColor": "#D00000"
|
|
//"label" : '${location}',
|
});
|
var styleJustGreenS1 = new OpenLayers.Style(
|
{
|
"strokeWidth": 5,
|
"pointRadius": 4, "fillColor": "#66AA66",
|
"fillOpacity": 0.7, "strokeColor": "#3030AA",
|
"labelYOffset": 0,
|
"labelAlign": "left",
|
"labelOutlineColor": "white",
|
"labelOutlineWidth": 0,
|
"fontSize": "12px",
|
"pointerEvents": "visiblePainted",
|
//"fontWeight": "bold",
|
"label" : "${number}" ,
|
"labelOutlineColor": "#FFCCCC",
|
"labelOutlineWidth": 5
|
});
|
// styles^
|
|
//var baselayer=createLayer('TGOS地型', {id:"tgos",baselayer:true,content:"http://gis.sinica.edu.tw/tgos/wmts",layerType:"tgos", layerid:"ROADMAP_W",projection:"EPSG:3857"});
|
//{layerType:'google'});
|
|
//var baselayer=createLayer('basemap0', {baselayer:true,layerType:'vector',projection:epsg3857,maxExtent:epsg3857_bounds
|
//});
|
|
//TTTHHIIISS
|
var baselayer=createLayer('basemap0', { layerType:"wmts" ,projection:"EPSG:3857",
|
baselayer:false,layerType:"wmts",content:"http://maps.nlsc.gov.tw/S_Maps/wmts", layerid:"EMAP",projection:"EPSG:3857"
|
});
|
|
//var baselayer=createLayer('basemap1', { layerType:"google" ,projection:"EPSG:3857"
|
// baselayer:false,layerType:"wmts",content:"http://maps.nlsc.gov.tw/S_Maps/wmts", layerid:"EMAP",projection:"EPSG:3857"
|
//});
|
|
|
var map;
|
var dwc;
|
if(typeof(maptag)=='undefined'||maptag=='') maptag='map';
|
map = new OpenLayers.Map(maptag, {
|
"projection": epsg3857,
|
"displayProjection" : wgs84,
|
allOverlays: true,
|
"layers": [baselayer],
|
//maxExtent:epsgws84_bounds,
|
eventListeners:
|
{
|
'featureover': onFeatureOver,
|
'featureout': onFeatureOut
|
},
|
controls:[new OpenLayers.Control.Navigation(), new OpenLayers.Control.Zoom(),new OpenLayers.Control.MousePosition(),new OpenLayers.Control.ScaleLine()
|
//,new OpenLayers.Control.LayerSwitcher()
|
],
|
//bounds:bounds,
|
center: new OpenLayers.LonLat(121.406784, 24.13276) //(121.506784, 23.03276)
|
// Google.v3 uses web mercator as projection, so we have to
|
// transform our coordinates
|
.transform(wgs84, epsg3857),
|
zoom:7
|
});
|
baselayer.setVisibility(true);
|
/*
|
map.events.register("zoomend", map, function(ev)
|
{
|
var zLv=this.getZoom();
|
if(zLv<=10){
|
parent.document.getElementById("L0panel").style.display='';
|
parent.document.getElementById("L1panel").style.display='none';
|
parent.document.getElementById("L2panel").style.display='none';
|
//show lv0
|
}
|
else if(zLv<=14){
|
//show lv1
|
parent.document.getElementById("L0panel").style.display='none';
|
parent.document.getElementById("L1panel").style.display='';
|
parent.document.getElementById("L2panel").style.display='none';
|
}
|
else
|
{
|
parent.document.getElementById("L0panel").style.display='none';
|
parent.document.getElementById("L1panel").style.display='none';
|
parent.document.getElementById("L2panel").style.display='';
|
//show lv2
|
}
|
|
});
|
*/
|
var tempLayer;
|
var queryHandle=new AProto();
|
|
//!! BUG ---@ PROJECTION
|
var facQuery = TPCFeatureInfoCtrl({ projection: "EPSG:3826", map: map, filterDgn: true}, function (e) {
|
var ctlloc_facquery=new CtlLocate(map,{layer:'highlight'});
|
|
if(typeof(e)!='undefined')
|
{
|
if(typeof( e.event)!='undefined')
|
{
|
if(e.event.features.length>0)
|
{
|
//however we require 4326, return X;
|
|
var paramsOfLocate={projection:e.event.object.projection,clearAll:true,
|
drawAs:'wkt',wkt:e.event.features[0].geometry.toString()};
|
/* skip
|
if(queryHandle.getConfig().locate||false)
|
{
|
paramOfLocate['zoomToRange']=true;
|
}*/
|
|
ctlloc_facquery.action(paramsOfLocate);
|
|
queryHandle.callAction(e.event.features[0].attributes);
|
}
|
}
|
return;
|
|
//debugger;
|
//var ctlLocate=null;
|
var dataParams=[];
|
for(var aFeatureKey in e.features)
|
{
|
var aFeature= e.features[aFeatureKey];
|
|
|
var labelName=fscMapping.hasOwnProperty(aFeature.attributes.tid)?fscMapping[aFeature.attributes.tid]:'其他設備';
|
//aPnlItem
|
|
|
var oidLabel=aFeature.attributes.hasOwnProperty('oid')?aFeature.attributes.oid:'0';
|
|
// attribFrm.items.get('tabpnl').add( aPnlItem );
|
var dataParam={};
|
if(useProxy)
|
{
|
dataParam["dmmsuser"]="";
|
dataParam["url"]=restUrl+'/json';
|
}
|
dataParam["distId"]=aFeature.attributes.did;
|
dataParam["clsId"]=aFeature.attributes.tid;
|
dataParam["oId"]=aFeature.attributes.oid;
|
|
dataParams.push(dataParam);
|
|
/*
|
ajaxJson.ajaxGet(
|
{
|
oid: aFeature.attributes.oid,
|
ret: aPnlItem,
|
url:((useProxy?OpenLayers.ProxyHost.split('?')[0]:restUrl+'/dmmsfeatureinfos.json') ),//'/geodmms/rest/dmmsfeatureinfos.json'),
|
header:{'Authorization': "Basic " + btoa('geodmms'+ ":" + 'geodmms')},
|
data:dataParam,
|
'success': function(request) {
|
//console.log(request);
|
var subPnl;
|
// lastJson= request.response;
|
var vjson=eval('('+request.response+')');
|
|
var vValueArray;
|
//alert('request.status is '+request.status);
|
//alert('vjson is '+vjson);
|
var vkeyCount=0;
|
for(var vkey in vjson[0])
|
{
|
vValueArray={items:[]};
|
var vName=(vjson[0][vkey].length>0)? vjson[0][vkey]:[];
|
var vValue;
|
if(vjson.length>1)
|
{
|
if(typeof(vjson[1][vkey])=='undefined'){vValue=[];}
|
else
|
vValue=(vjson[1][vkey].length>0)? vjson[1][vkey]:[]
|
}
|
else
|
vValue=[];
|
// var vValue=(vjson[0][vkey].length>1)? vjson[1][vkey]:'';
|
for(var idx=0;idx<vName.length;idx++)
|
{
|
vValueArray.items.push({name:vName[idx],value:(vValue.length>idx)?vValue[idx]:""});
|
}
|
|
var subStore= Ext.create('Ext.data.Store', {
|
fields: ['name', 'value'],
|
data: vValueArray,
|
proxy: {
|
type: 'memory',
|
reader: {
|
type: 'json',
|
root: 'items'
|
}
|
}
|
});
|
// lastStore= subStore ;
|
// console.log(subStore) ;
|
|
var subPnl=Ext.create('Ext.grid.Panel',
|
{title:vkey+(vkeyCount<1?('('+this.oid+')'):''), columns: [
|
{text: '屬性名稱', width: 140, sortable: true, dataIndex: 'name'},
|
{text: '屬性值', flex: 1, sortable: true, dataIndex: 'value'}],
|
store: subStore
|
|
}) ;
|
attribFrm.items.get('tabpnl').items.get(this.ret.id).add(subPnl);
|
//debugger;
|
//aPnlItem.add(subPnl);
|
attribFrm.items.get('tabpnl').setActiveTab(aPnlItem);
|
vkeyCount++;
|
}
|
|
}
|
}) ;
|
*/
|
}
|
|
if(adptProc)
|
{
|
adptProc(dataParams);
|
}
|
//debugger;
|
} //{layout:'fit',width:800,height:480}
|
|
});
|
|
for(var idx=0;idx<layerList.length;idx++)
|
{
|
|
var thisLayerDef= layerList[idx];
|
if(map.getLayersByName(thisLayerDef.id).length==0)
|
{
|
var tempLayer;
|
var content_forLayer;
|
if(typeof(thisLayerDef.layerinfo.content)!='undefined')
|
{
|
content_forLayer = thisLayerDef.layerinfo.content;
|
|
}
|
else
|
content_forLayer=wmsUrl ;
|
var optionOfLayer={layerType:thisLayerDef.layerinfo.layerType,
|
layerid:thisLayerDef.layerinfo.layerid,content:content_forLayer,
|
projection:thisLayerDef.layerinfo.projection};
|
/* if(typeof(thisLayerDef.proj4JSPath)!='undefined')
|
{
|
optionOfLayer['proj4JSPath']=thisLayerDef.proj4JSPath;
|
} */
|
|
tempLayer=createLayer(thisLayerDef.id,optionOfLayer);
|
|
map.addLayer(tempLayer);
|
|
tempLayer.setVisibility(thisLayerDef.showdef);
|
|
if(thisLayerDef.featureinfo)
|
{
|
if(facQuery!=null)
|
{
|
facQuery.layers.push(tempLayer);
|
}
|
}
|
}
|
else
|
{
|
// console.log('exist:'+thisLayerDef.id)
|
map.getLayersByName(thisLayerDef.id)[0].setVisibility(thisLayerDef.showdef);
|
}
|
}
|
var vLayerArray={items:layerList};
|
//vLayerStore
|
//facQuery.activate();
|
|
//----
|
|
var markLayer=createLayer('markup',{
|
layerType:'vector',// ,styleMap:styleHighLight
|
styleMap:new OpenLayers.StyleMap({
|
"default" : styleYellow,
|
"select": styleHighLight
|
})
|
});
|
map.addLayer(markLayer);
|
|
tempLayer=createLayer('drawTemp',{
|
layerType:'vector'
|
/*styleMap:new OpenLayers.StyleMap({
|
"default" : styleJustGreen,
|
"select": styleJustGreenS1
|
})*/
|
});
|
|
|
|
var highlightLayer=createLayer('highlight',{
|
layerType:'vector',styleMap:styleHighLightYellow
|
});
|
|
map.addLayer(highlightLayer);
|
|
extMapResultion(map,24);
|
|
dwc=new DrawControl(tempLayer,{map:map});
|
map.addLayer(tempLayer);
|
|
|
var visualLayer=createLayer('visual',{
|
layerType:'vector'
|
});
|
map.addLayer(visualLayer);
|
|
var visualpoint= new OpenLayers.Control.DrawFeature(visualLayer,
|
OpenLayers.Handler.Point);
|
var visualwkt=new CtlGetWKT(map,{srcLayer:"visual"});
|
visualLayer.setVisibility(false);
|
visualpoint.setMap(map);
|
var callbackVP=function(evt){};
|
var vpAdded=function(evt)
|
{
|
visualpoint.deactivate();
|
if(typeof(callbackVP)=="function")
|
{
|
var result=visualwkt.parser(evt.feature,{geometryType:'featurePoint'});
|
callbackVP(result);
|
|
}
|
|
}
|
dwc["toggleVP"]=function(callVP,configVP)
|
{
|
callbackVP=callVP;
|
visualpoint.activate();
|
|
}
|
visualpoint.events.register('featureadded', visualpoint,vpAdded);
|
|
//dwc.addControl('getpoint',visualpoint);
|
dwc.addControl('facquery', facQuery);
|
|
|
var showquery=function(params)
|
{
|
var bindProperty=function(vjson)
|
{
|
$("#propertiesA")[0].innerHTML="<p>"+params.name+"</p><p>"+vjson[0].name+"</p>";
|
//$("properties.panel-collapse")
|
}
|
|
var queryMethod= offlineRest? restUrl+ params.fcid+'-'+ params.gid+'.json' : 'tpctyphoon.json';
|
|
|
//$("#propertiesA")[0].innerHTML="<p>"+params.name+"</p>";
|
$("#propertiesA")[0].innerHTML='<table class="table table-striped table-bordered table-rwd">'
|
+'<tr class="tr-only-hide">'
|
+'<th>名稱</th>'
|
+(typeof(params.info)=="undefined" ?'': '<th>資訊</th>')
|
+'</tr>'
|
+'<tr>'
|
+'<td data-th="名稱">'+params.name+'</td>'
|
+(typeof(params.info)=="undefined" ?'': '<td data-th="資訊">'+params.info+'</td>')
|
+'</tr>'
|
+'</table>';
|
return;
|
|
$.ajax({
|
srcTitle:params.name,
|
url:queryMethod,
|
dataType: 'json',
|
//headers: {'Authorization': "Basic " + btoa('geodmms' + ":" + 'geodmms')},
|
crossDomain: true,//sorry not for IE
|
async:false,
|
data: params,
|
success: function(result)
|
{
|
//debugger;
|
//console.log(result);
|
// debugger;
|
var subPnl;
|
// lastJson= request.response;
|
var vjson = eval('(' + result.responseText + ')');
|
bindProperty(vjson);
|
return;
|
/*
|
var vValueArray;
|
//alert('request.status is '+request.status);
|
//alert('vjson is '+vjson);
|
var vkeyCount = 0;
|
for (var vkey in vjson[0]) {
|
vValueArray = {items: []};
|
var vName = (vjson[0][vkey].length > 0) ? vjson[0][vkey] : [];
|
var vValue;
|
if (vjson.length > 1) {
|
if (typeof(vjson[1][vkey]) == 'undefined') {
|
vValue = [];
|
}
|
else
|
vValue = (vjson[1][vkey].length > 0) ? vjson[1][vkey] : []
|
}
|
else
|
vValue = [];
|
// var vValue=(vjson[0][vkey].length>1)? vjson[1][vkey]:'';
|
for (var idx = 0; idx < vName.length; idx++) {
|
vValueArray.items.push({name: vName[idx], value: (vValue.length > idx) ? vValue[idx] : ""});
|
}
|
|
}
|
*/
|
}
|
,
|
error: function(err_result)
|
{
|
if(err_result.status=="200")
|
{
|
|
var vjson = eval('(' + err_result.responseText + ')');
|
//debugger;
|
bindProperty(vjson);
|
}
|
else
|
$("#propertiesA")[0].innerHTML="<p>無資料</p>";
|
|
}
|
});
|
|
|
};
|
|
|
dwc['queryOne']=function(callQuery,newconfig)
|
{
|
queryHandle.setAction(callQuery||showquery, newconfig);
|
|
//dwc.setToggleFac('FCID=' + newconfig.fcid);
|
|
dwc.toggle('facquery');
|
|
//dwc.setToggleFac("");
|
|
}
|
|
var ctlLocate = new CtlLocate(map, { layer: 'highlight' });
|
var createQueryFrm = function (layoutOfQuery, option) {
|
|
if (typeof (option) == "undefined") option = {};
|
if (typeof (option.qconfig) == "undefined")
|
option["qconfig"] = { catelog: 'default' };
|
|
var qData;
|
var featureQueryHandler = new twdQuery(option.qconfig, function (e) {
|
qData = e.body;
|
});//handler?
|
var dummy = [];
|
var idx;
|
for (idx = 0; idx < layoutOfQuery.column.length; idx++) dummy.push("0");
|
/*
|
{
|
querybyDgnUfid: true,
|
DGNID: e.event.features[idx].data.DGNID,
|
UFID: e.event.features[idx].data.UFID
|
}
|
*/
|
if (option.querybyDgnUfid) {
|
featureQueryHandler.queryAPI(
|
{
|
p0: layoutOfQuery.group, p1: layoutOfQuery.name, cnd: [option.DGNID, option.UFID]
|
});
|
} else if (typeof (option.qs) != "undefined") {
|
|
featureQueryHandler.queryAPI(
|
{
|
p0: layoutOfQuery.group, p1: layoutOfQuery.name, cnd: option.qs
|
});
|
}
|
else {
|
featureQueryHandler.queryAPI(
|
{
|
p0: layoutOfQuery.group, p1: layoutOfQuery.name, cnd: (dummy.length == 0 ? "0" : dummy.join(","))
|
});
|
}
|
var qSchema = featureQueryHandler.getResult().head;
|
|
//qData = featureQueryHandler.getResult().body;
|
//var fields = featureQueryHandler.getResult().head.ColumnKey;
|
//.ColumnInfo[0]
|
//{key: "DGNID", name: "圖號", hide: false, dtype: "string", index: "DGNID"} // jqgrid-format
|
var evtItem = qSchema.LinkInfo;//:[{"key":"LONLAT","action":"LocateByLL","cols":["LON","LAT"]}]
|
var fields = [];
|
var columns = [];
|
var lstbuttons = [];
|
|
var gridFunc = {};
|
|
gridFunc["GETVALUE"] = function (vGrid, cols) {
|
//var vGrid = this.up().up();
|
var idx;
|
var result = [];
|
var vSel = vGrid.getSelectionModel().getSelection();
|
if (vSel.length > 0) {
|
|
for (idx = 0; idx < cols.length; idx++) {
|
var tmpcol = vSel[0].getData()[cols[idx]];
|
result.push(tmpcol);
|
}
|
//cols
|
}
|
return result;
|
}
|
//funcHub["ctlLocate"] = ctlLocate;
|
//pub
|
gridFunc["LocateByLL"] = function (ll) {
|
if (ll.length > 1) {
|
ctlLocate.action({ clearAll: true, point: { x: ll[0], y: ll[1] }, zoomLevel: 19, projection: wgs84, drawAs: 'point', hide: 'N', zoomToCenter: true });
|
}
|
}
|
gridFunc["LocateBy97"] = function (l97) {
|
if (l97.length > 1) {
|
ctlLocate.action({ clearAll: true, point: { x: l97[0], y: l97[1] }, zoomLevel: 19, projection: tw97, drawAs: 'point', hide: 'N', zoomToCenter: true });
|
}
|
}
|
gridFunc["LocateBy67"] = function (l67) {
|
if (l67.length > 1) {
|
ctlLocate.action({ clearAll: true, point: { x: l67[0], y: l67[1] }, zoomLevel: 19, projection: tw67, drawAs: 'point', hide: 'N', zoomToCenter: true });
|
}
|
}
|
|
|
|
|
|
|
|
//
|
|
var CTLFunLinkInfo = function (aEvtItem, gridFunc) {
|
this.action = function () {
|
|
var vGrid = this.up().up();
|
var dtCol = gridFunc.GETVALUE(vGrid, aEvtItem.cols);
|
gridFunc[aEvtItem.action](dtCol);
|
}
|
}
|
var idxE;
|
for (idxE = 0; idxE < evtItem.length; idxE++) {
|
var ctBtnClick = new CTLFunLinkInfo(evtItem[idxE], gridFunc);
|
|
lstbuttons.push({
|
xtype: 'button', text: evtItem[idxE].key, handler: ctBtnClick.action
|
});
|
|
}
|
|
|
|
for (idx = 0; idx < qSchema.ColumnInfo.length; idx++) {
|
fields.push({ name: qSchema.ColumnInfo[idx].key, type: qSchema.ColumnInfo[idx].dtype });//dateFormat
|
if (qSchema.ColumnInfo[idx].name == "X(97)" || qSchema.ColumnInfo[idx].name == "Y(97)" || qSchema.ColumnInfo[idx].name == "值")
|
continue;
|
columns.push({
|
text: qSchema.ColumnInfo[idx].name,
|
hide: qSchema.ColumnInfo[idx].hide,
|
//flex: 1, 導致欄位被壓縮
|
sortable: true,
|
asText: qSchema.ColumnInfo[idx].dtype,// == "string" ? "asText" : "asText"
|
dataIndex: qSchema.ColumnInfo[idx].key
|
});
|
|
}
|
var qStore = Ext.create('Ext.data.ArrayStore', {
|
//storeId: 'simpsonsStore',
|
fields: fields,
|
data: qData.vList
|
/*
|
proxy: {
|
type: 'memory',
|
reader: {
|
type: 'json',
|
root: 'items'
|
}
|
}*/
|
});
|
|
|
//{group: "HYDRANT", name: "q", displayname: "消防栓", column: Array[2]}
|
var colQuery = [];
|
var idxCol;
|
//{cname: "圖號", ctype: "num", require: true, code: Array[0]}
|
//code 未寫(qVal,nVal)
|
|
for (idxCol = 0; idxCol < layoutOfQuery.column.length; idxCol++) {
|
var colType;
|
if (layoutOfQuery.column[idxCol].ctype == "num")
|
colType = 'numberfield';
|
else if (layoutOfQuery.column[idxCol].ctype == "geom")
|
colType = 'button';
|
else
|
colType = 'textfield';
|
//colType = layoutOfQuery.column[idxCol].ctype == "num" ? 'numberfield' : 'textfield';
|
|
if (layoutOfQuery.column[idxCol].code.length == 0) {
|
if (layoutOfQuery.column[idxCol].ctype == 'geom') {//is geom
|
colQuery.push({
|
xtype: colType,
|
text: layoutOfQuery.column[idxCol].cname,
|
scale: 'large',
|
// value:'userwkt',
|
valueFun: function () {
|
var tempPP = drawControl.getWkt();
|
var pts = [];
|
if (typeof (tempPP.features) == "undefined") return "";
|
if (tempPP.features.length > 0) {
|
|
for (var idxOfPP = 0; idxOfPP < tempPP.features[0].points.length; idxOfPP++) {
|
pts.push(parseInt(tempPP.features[0].points[idxOfPP].x));
|
pts.push(parseInt(tempPP.features[0].points[idxOfPP].y));
|
}
|
|
}
|
return pts.join(",");
|
},
|
|
handler: function () {
|
var custFun = function (setv) {
|
userwkt = setv;
|
};
|
gridFunc['DRAWPOLYGON'](layoutOfQuery.name);
|
|
}
|
});
|
}
|
else {
|
|
colQuery.push({
|
xtype: colType,
|
fieldLabel: layoutOfQuery.column[idxCol].cname,
|
allowBlank: !layoutOfQuery.column[idxCol].require
|
});
|
}
|
} else {//NValue
|
/* var lstStore = Ext.create('Ext.data.Store', {
|
|
fields: ['name','value'],
|
data: layoutOfQuery.column[idxCol].code
|
});*/
|
colQuery.push({
|
xtype: 'combobox',
|
store: { xtype: 'store', fields: ['name', 'value'], data: layoutOfQuery.column[idxCol].code },
|
fieldLabel: layoutOfQuery.column[idxCol].cname,
|
queryMode: 'local',
|
displayField: 'name',
|
valueField: 'value'
|
// allowBlank: !layoutOfQuery.column[idxCol].require
|
});
|
|
|
//http://localhost:1240/FMQuery/LANDMARK.0/q/0?catelog=theme
|
//debugger;
|
}
|
|
|
}
|
|
var extQuerypanel1;
|
//------------->SelectLayout
|
if (option.SelectLayout || 'default' == 'onlyResult') {
|
|
extQuerypanel1 = extQuerypanel1 = Ext.create('Ext.window.Window', {
|
id: "extQuerypanel1",
|
title: '查詢',
|
width: 400, height: 300,
|
closable: true, //layout:'fit', //'anchor',
|
layout: {
|
type: 'vbox',
|
align: 'stretch'
|
},
|
//items:[{xtype:'button',text:'test'},{xtype:'button',text:'test'},{xtype:'button',text:'test'} ],
|
//bbar:tbl1,
|
items: [
|
{
|
xtype: 'gridpanel',
|
store: qStore,
|
columns: columns,
|
flex: 1,
|
|
bbar: lstbuttons //[{ xtype: 'button', text: '定位' }, { xtype: 'button', text: '查詢' }]
|
}
|
]
|
});
|
extQuerypanel1.showAt(Ext.getBody().getViewSize().width - 400, 10);
|
}
|
else {
|
|
extQuerypanel1 = Ext.create('Ext.window.Window', {
|
id: "extQuerypanel1",
|
title: '查詢',
|
width: 550, height: 400,
|
closable: true, //layout:'fit', //'anchor',
|
layout: {
|
type: 'vbox',
|
align: 'stretch'
|
},
|
//items:[{xtype:'button',text:'test'},{xtype:'button',text:'test'},{xtype:'button',text:'test'} ],
|
//bbar:tbl1,
|
items: [{
|
flex: 1,
|
name: 'queryCnd',
|
xtype: 'panel', title: layoutOfQuery.displayname, collapsible: true,
|
items: colQuery,
|
/*
|
//layeroutOfQuery COND
|
items: [{
|
xtype: 'textfield',
|
name: 'dgnid',
|
fieldLabel: '圖號'
|
}, {
|
xtype: 'textfield',
|
name: 'ufid',
|
fieldLabel: '流水號'
|
}],*/
|
bbar: [{
|
xtype: 'button', text: '送出', handler: function () {
|
|
var allitem = this.up().up().items.items;
|
var idxOfI;
|
var result = [];
|
for (idxOfI = 0; idxOfI < allitem.length; idxOfI++) {
|
var tval = allitem[idxOfI].value;
|
var tvaltype = allitem[idxOfI].valueFun;
|
if (typeof (tvaltype) == "function") {
|
tval = tvaltype();
|
}
|
if (typeof (tval) == "undefined") tval = "null";
|
//if (tval == "userwkt") tval = userwkt;
|
result.push(tval);
|
}
|
|
featureQueryHandler.queryAPI(
|
{
|
p0: layoutOfQuery.group, p1: layoutOfQuery.name, cnd: result.join(',')
|
}, qStore, function (e) {
|
qStore.loadData(e.body.vList);
|
// debugger;
|
});
|
|
|
}
|
},
|
{
|
xtype: 'button', text: '取消', handler: function () {
|
this.up().up().up().close();
|
}
|
}]
|
},
|
{
|
xtype: 'gridpanel',
|
store: qStore,
|
columns: columns,
|
flex: 2,
|
/*
|
columns: [{
|
header: 'Name', dataIndex: 'name'
|
},
|
{
|
header: 'Email', dataIndex: 'email', flex: 1
|
},
|
{
|
header: 'Phone', dataIndex: 'phone'
|
}],*/
|
bbar: lstbuttons //[{ xtype: 'button', text: '定位' }, { xtype: 'button', text: '查詢' }]
|
}
|
]
|
});
|
extQuerypanel1.showAt(80, 10);
|
}
|
|
}
|
//dwc['qf'] = createQueryFrm;
|
|
var fpControl = new OpenLayers.Control.FeaturePopups({
|
boxSelectionOptions: {},
|
layers: [
|
[
|
// Uses: Templates for hover & select and safe selection
|
markLayer, {templates: {
|
// hover: single & list
|
hover: '${.popup}'
|
//hoverList: '<b>編號:</b>${.number}<br /><b>場所:</b>${.location}<br /><b>位置:</b>${.address}<br />${html}',
|
//hoverItem: '<b>編號:</b>${.number}<br />',
|
// select: single & list
|
//single: '<li><b>編號:</b>${.number}</li><li><b>場所:</b>${.location}</li><li><b>位置:</b>${.address}<li><a href="#" onClick="window.open(\'${.hyperlink}\',\'attribFrm\')">詳細資訊</a></li>',
|
//single: '${showHyperlink()} <div><h2>${.name}</h2>${.description}</div>',
|
//item: '${popURL()} <li><b>編號:</b>${.number}</li><li><b>場所:</b>${.location}</li><li><b>位置:</b>${.address}<br /></li>'
|
// +'<li><a href="${.hyperlink}" >資訊</a></li>'
|
}}
|
]
|
]
|
});
|
//selectionchanged
|
map.addControl(fpControl);
|
|
selectControl = new OpenLayers.Control.SelectFeature(markLayer,
|
{onSelect: dwc.Events.onFeatureSelect, onUnselect: dwc.Events.onFeatureUnselect
|
|
});
|
|
|
//dwc.addToolBarButton("查詢",{eventId:"tpcquery",iconCls:'tbquery'},null);
|
/*dwc.addToolBarButton("更新",{eventId:"refresh",iconCls:"refresh"},function(e)
|
{
|
|
|
});*/
|
// dwc.addToolBarButton("定位",{eventId:"cclocate",iconCls:'tblocate'},function(e){
|
// });
|
/*
|
var locateFrm= Ext.create('widget.window', {
|
layout:'fit',
|
title: '座標定位',
|
|
width:300,height:200,
|
items:[{xtype:'tabpanel' ,items:[
|
|
{title:'經緯度',items:[
|
{xtype: 'textfield', id: 'lon',fieldLabel: '經度(Lon)', allowBlank: false,labelAlign:'right' },
|
{xtype: 'textfield', id: 'lat',fieldLabel: '緯度(Lat)', allowBlank: false ,labelAlign:'right'},
|
{xtype: 'button', text :'定位',handler:function(){
|
if(ctlLocate==null)
|
ctlLocate=new CtlLocate(map);
|
var x=parseFloat(this.up().items.get('lon').getValue());
|
var y=parseFloat(this.up().items.get('lat').getValue());
|
ctlLocate.action({clearAll:true,point:{x:x,y:y},projection:wgs84 ,drawAs:'point',zoomToCenter:true});
|
|
}}
|
]}
|
]
|
});
|
|
locateFrm.show();});
|
|
*/
|
|
|
//toolbar = dwc.getToolbar(map,{});
|
//toolbar=dwc.getExtToolbar(map);
|
//ext
|
//vLayerGrid
|
|
//extToolpanel1
|
|
//extToolpanel2
|
|
//var scale = new OpenLayers.Control.Scale();
|
//map.addControl(scale);
|
|
// map.addControl(new OpenLayers.Control.LayerSwitcher());
|
|
|
//ctlLocate=new CtlLocate(map,{});
|
|
//facQuery.activate();
|
|
map.addControl(selectControl);
|
|
selectControl.activate();
|
|
/* zoom to extent range from geojson data */
|
//map.zoomToExtent(hydraulicPoint.getDataExtent());
|
dwc.queryOne();
|
return dwc;
|
}
|
function refreshMap(scope){
|
var ddt= new Date();
|
var dateStr='20150611'; //String(ddt.getYear()+1900)+String(ddt.getMonth()+1)+String(ddt.getDate());
|
var weekPeroid=String(ddt.getDay());
|
var tmpLayers0;
|
tmpLayers0=scope.getLayersByName("paverange");
|
setCQL(tmpLayers0[0],"PERIOD='"+weekPeroid+"'");
|
tmpLayers0[0].setVisibility(true);
|
tmpLayers0=scope.getLayersByName("roadpath");
|
setCQL(tmpLayers0[0],"DT0='"+dateStr+"'");
|
tmpLayers0[0].setVisibility(true);
|
tmpLayers0=scope.getLayersByName("caselocate");
|
setCQL(tmpLayers0[0],"DT0='"+dateStr+"'");
|
tmpLayers0[0].setVisibility(true);
|
}
|
|
//init();
|