arcgis api JavaScript打印地圖圖例顯示不正確

問題1:地圖上以圖層樣式以PictureMarkerSymbol的打印不出現或出現被替換

在地圖上使用圖片圖標作爲樣式,是一件很正常的事情。
打印的時候,在被打印的地圖上沒有看到這個圖層。
反覆測試後,並沒有找到原因,但是掌握了出現的情況。

背景:查詢時將查詢結果加載到地圖上,其中圖標的樣式使用小氣球圖片png格式。

  • 情況一

    設置:圖層的樣式使用PictureMarkerSymbol,生成每一個graphic時,參數symbol爲null
    打印結果:看不到當前圖層

  • 情況二

    設置:圖層是否設置樣式都可以,生成每一個graphic時,參數symbol爲PictureMarkerSymbol樣式
    打印結果:可以看到當前圖層,但是每一個對象原本的圖片圖標被替換,替換爲arcgis最基本的樣式,顯示在打印的地圖上。

  • 解決辦法:

    將圖片樣式替換掉,替換爲arcgis中SimpleMarkerSymbol的樣式

問題2:當圖層以colorInfo渲染時,圖例顯示override

圖層使用colorInfo渲染方式


       // parameter
       var lineWidth = config.symbol.lineWidth,
            lineColor = config.symbol.lineColor,
            legendTitle = config.legendTitle,
            // stopsValue = config.renderer.stopsValue,
            stopsNum = config.renderer.stopsNum,
            stopsColor = config.renderer.stopsColor,
            type = config.renderer.type,
            field = config.renderer.field,
            normalizationField = config.renderer.normalizationField;

        var stopsValue = getStopsValue(data, stopsNum);

        // symbol
        var line = new esri.symbol.SimpleLineSymbol().setWidth(lineWidth).setColor(new esri.Color(lineColor));
        var symbol = new esri.symbol.SimpleFillSymbol().setOutline(line);

        var stops = [];
        for (var i = 0; i < stopsValue.length; i++) {
            var b = {
                "value": stopsValue[i],
                "color": new esri.Color(stopsColor[i])
            }
            stops.push(b);
        }

        var r = new esri.renderer.SimpleRenderer({
            symbol: symbol,
            visualVariables: [{
                type: type,
                field: field,
                normalizationField: normalizationField, 
                legendOptions: {
                    showLegend: false,
                    title: legendTitle
                },              
                stops: stops
            }]
        });     

arcgis api v3.21打印出地圖上的圖例:
arcgis v3.21 圖例
arcgis api v3.21 web系統上的圖例:
這裏寫圖片描述
arcgis api v3.17 web系統上的圖例:
這裏寫圖片描述
使用arcgis api v3.20及以下的API版本進行打印,都會報錯:
這裏寫圖片描述

有可能是版本帶來的問題。待解決。

問題3:

當打印服務和打印的圖層不在同一個網段時,則不能打印正確

可以打印

app.printUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
var permitUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/MapServer/1";

打印失敗

app.printUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
var permitUrl = ""http://172.16.1.183:6080/arcgis/rest/services/js/8"";

問題4. 發佈圖層使用圖片圖標,地圖和圖例均可以正確顯示

地圖在發佈時就使用圖片,則發佈後的地圖可以被正確打印,地圖上圖標沒有發生變化,圖例也是正確的。

以機場圖層爲例,圖例正確:
圖例正確

地圖正確:(忽略文字亂碼)
地圖正確

問題5. 中文標註亂碼

以機場圖層爲例,亂碼部分本應該是圖層的標註名稱。待解決
圖層本身沒有標註,增加了labelLayer圖層,給圖層增加標註

中文標註亂碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章