执行动态分段时,第一次刷新页面显示referenceLineM参数不存在,再次刷新就会显示路由数据集不存在。关闭isever打开工作空间后发现路由数据集就莫名其妙的消失了,请问这是为什么?以下是我的js代码,请老师帮忙看一下哪里有问题,十分感谢。
var map, layer, themeLayer,
url="http://localhost:8090/iserver/services/map-bike-sharing/rest/maps/beijing",
url2="http://localhost:8090/iserver/services/spatialAnalysis-bike-sharing/restjsr/spatialanalyst";
function init(){
layer = new SuperMap.Layer.TiledDynamicRESTLayer("beijing", url, { transparent: true, cacheEnabled: true }, { maxResolution: "auto" });
layer.events.on({"layerInitialized":addLayer});
map = new SuperMap.Map("map",{allOverlays:true, controls: [
new SuperMap.Control.LayerSwitcher(),
new SuperMap.Control.ScaleLine(),
new SuperMap.Control.Zoom(),
new SuperMap.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}})]
});
}
function addLayer() {
map.addLayers([layer]);
map.setCenter(new SuperMap.LonLat(12963487.7761907, 4852179.97174134),12);
}
//生成动态分段
function GenerateSpatialData(){
clearThemeLayer();
//配置数据返回Option
var option = new SuperMap.REST.DataReturnOption({
expectCount: 1000,
dataset: "Routes@北京市",
deleteExistResultDataset: true,
dataReturnMode: SuperMap.REST.DataReturnMode.DATASET_ONLY
}),
//配置动态分段Parameters
parameters = new SuperMap.REST.GenerateSpatialDataParameters({
routeTable: "Routes@北京市",
routeIDField: "SmID",
eventTable: "EventTable@北京市",
eventRouteIDField: "SmID",
measureStartField: "FromM",
measureEndField: "ToM",
dataReturnOption: option
}),
//配置动态分段iService
iService = new SuperMap.REST.GenerateSpatialDataService(url2, {
eventListeners: {
processCompleted: generateCompleted,
processFailed: generateFailded
}
});
//execute
iService.processAsync(parameters);
//completed
function generateCompleted(generateSpatialDataEventArgs) {
//配置专题样式
var style1, style2, style3;
style1 = new SuperMap.REST.ServerStyle({
fillForeColor: new SuperMap.REST.ServerColor(242, 48, 48),
lineColor: new SuperMap.REST.ServerColor(242, 48, 48),
lineWidth: 1
});
style2 = new SuperMap.REST.ServerStyle({
fillForeColor: new SuperMap.REST.ServerColor(255, 159, 25),
lineColor: new SuperMap.REST.ServerColor(255, 159, 25),
lineWidth: 1
});
style3 = new SuperMap.REST.ServerStyle({
fillForeColor: new SuperMap.REST.ServerColor(91, 195, 69),
lineColor: new SuperMap.REST.ServerColor(91, 195, 69),
lineWidth: 1
});
//配置专题项
var themeUniqueIteme1, themeUniqueIteme2, themeUniqueIteme3;
themeUniqueIteme1 = new SuperMap.REST.ThemeUniqueItem({
unique: "3",
style: style1
});
themeUniqueIteme2 = new SuperMap.REST.ThemeUniqueItem({
unique: "2",
style: style2
});
themeUniqueIteme3 = new SuperMap.REST.ThemeUniqueItem({
unique: "1",
style: style3
});
var themeUniqueItemes=[themeUniqueIteme1, themeUniqueIteme2, themeUniqueIteme3];
var themeUnique = new SuperMap.REST.ThemeUnique({
uniqueExpression: "type_L",
items: themeUniqueItemes,
defaultStyle: new SuperMap.REST.ServerStyle({
fillForeColor: new SuperMap.REST.ServerColor(48, 89, 14),
lineColor: new SuperMap.REST.ServerColor(48, 89, 14)
})
});
var themeParameters = new SuperMap.REST.ThemeParameters({
themes: [themeUnique],
datasetNames: ["SpatialData"],
dataSourceNames: ["北京市"]
});
var themeService = new SuperMap.REST.ThemeService(url2, {
eventListeners:{
"processCompleted": themeCompleted,
"processFailed": themeFailed
}
});
themeService.processAsync(themeParameters);
function themeCompleted(themeEventArgs) {
if(themeEventArgs.result.resourceInfo.id) {
themeLayer = new SuperMap.Layer.TiledDynamicRESTLayer("路况信息",
url2, {cacheEnabled:false, transparent: true, layersID: themeEventArgs.result.resourceInfo.id}, {"maxResolution": "auto"});
themeLayer.events.on({"layerInitialized": addThemeLayer});
}
}
function addThemeLayer() {
map.addLayer(themeLayer);
}
function themeFailed(e) {
alert(e.error.errorMsg);
}
}
//failed
function generateFailded(e) {
alert(e.error.errorMsg);
}
}
//移除专题图层
function clearThemeLayer(){
if(themeLayer) {
map.removeLayer(themeLayer,true);
themeLayer = null;
}
}