var xmuss = mapPoint.x - ((mapPoint.x - this.inputPoints[this.inputPoints.length-2].x)/2); var ymuss = mapPoint.y - ((mapPoint.y - this.inputPoints[this.inputPoints.length-2].y)/2); var winkelmuss = (Math.atan2((this.inputPoints[this.inputPoints.length-2].y - mapPoint.y), (this.inputPoints[this.inputPoints.length-2].x - mapPoint.x))*180)/Math.PI; var pt = new esri.geometry.Point(xmuss, ymuss, this._map.spatialReference); var textSymbol = new esri.symbol.TextSymbol(); textSymbol.setColor(new dojo.Color([0,0,0])).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD)); var gemessen = '123'; textSymbol.text = dojo.number.format(gemessen.toFixed(1), {pattern: this.numberPattern}) + zeichen; textSymbol.angle = 90; this.textGraphic=new esri.Graphic(); this.textGraphic.setSymbol(textSymbol); this.textGraphic.setGeometry(pt); this._map.graphics.add(this.textGraphic); this.measureGraphics.push(this.textGraphic);
//in the init() // get print templates from the export web map task var printInfo = esri.request({ "url": app.printUrl, "content": { "f": "json" } }); printInfo.then(handlePrintInfo, handleError); //Print Funktion function handlePrintInfo(resp) { var layoutTemplate, templateNames, mapOnlyIndex, templates; layoutTemplate = dojo.filter(resp.parameters, function(param, idx) { return param.name === "Layout_Template"; }); if ( layoutTemplate.length == 0 ) { console.log("print service parameters name for templates must be \"Layout_Template\""); return; } templateNames = layoutTemplate[0].choiceList; // remove the MAP_ONLY template then add it to the end of the list of templates mapOnlyIndex = dojo.indexOf(templateNames, "MAP_ONLY"); if ( mapOnlyIndex > -1 ) { var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0]; templateNames.push(mapOnly); } // create a print template for each choice templates = dojo.map(templateNames, function(ch) { var plate = new esri.tasks.PrintTemplate(); plate.layout = plate.label = ch; plate.format = "PDF"; plate.layoutOptions = { "authorText": "Stadt Osnabrück Fachbereich Städtebau", "copyrightText": "Copyright Stadt Osnabrück", "legendLayers": [], "titleText": "Messen", "scalebarUnit": "Kilometers" }; return plate; }); // create the print dijit app.printer = new esri.dijit.Print({ "map": app.map, "templates": templates, url: app.printUrl }, dojo.byId("print_button")); app.printer.startup(); } function handleError(err) { console.log("Something broke: ", err); }
Unfortunately, I'm not aware of a way to remove the color flag from the JSON without doing some manual manipulation...
dojo.forEach(_markupTool.markupTextLayer.graphics, function (item) { //Remove color property from each graphics' symbol - trying GP Print Task bug workaround if (item && item.symbol && item.symbol.color) { delete item.symbol.color; } });
*snip* {"id":"graphicsLayer47","featureCollection":{"layers":[{"layerDefinition":{"name":"pointLayer","geometryType":"esriGeometryPoint"},"featureSet":{"geometryType":"esriGeometryPoint","features":[{"geometry":{"x":-13619523.035374189,"y":6030400.527597526,"spatialReference":{"wkid":102100}},"symbol":{"color":[0,0,0,255],"type":"esriTS","angle":0,"xoffset":0,"yoffset":0,"text":"linguist","align":"start","decoration":"none","rotated":false,"kerning":true,"font":{"size":"16pt","style":"normal","variant":"normal","weight":"bold","family":"Arial"}}}]}}]}}],"exportOptions": *snip*
function scrubPrintTask(ioArgs) { // inspect ioArgs //console.log(ioArgs.url, ioArgs.content); if (ioArgs.url.indexOf("ExportWebMap") > -1) { if (ioArgs.content.Web_Map_as_JSON) { ioArgs.content.Web_Map_as_JSON = ioArgs.content.Web_Map_as_JSON.replace('"symbol":{"color":[0,0,0,255],"type":"esriTS"', '"symbol":{"type":"esriTS"'); } } // don't forget to return ioArgs. return ioArgs; }
"symbol":{ "type":"esriTS", "angle":45, "xoffset":0, "yoffset":0, "text":"This is a test.", "align":"middle", "decoration":"none", "rotated":false, "kerning":true, "font":{ "size":"16pt", "style":"normal", "variant":"normal", "weight":"bold", "family":"Arial" } }
ioArgs.content.Web_Map_as_JSON = ioArgs.content.Web_Map_as_JSON.replace(/\"size\":\"16pt\"/g, '"size":16'); ioArgs.content.Web_Map_as_JSON = ioArgs.content.Web_Map_as_JSON.replace(/\"angle\":/g, '"angle":-');
{ "mapOptions": { "showAttribution": true, "extent": { "xmin": 283587.7543757293, "ymin": 78359, "xmax": 342600.2456242707, "ymax": 113602, "spatialReference": { "wkid": 27700 } }, "spatialReference": { "wkid": 27700 }, "scale": 155427.79855309209 }, "operationalLayers": [{ "id": "mainbasemaps", "title": "mainbasemaps", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "http://eddc-gis2/arcgis/rest/services/BaseMapOSNonTiled/MapServer", "visibleLayers": null, "layers": [] }, { "id": "altbasemaps", "title": "altbasemaps", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "http://eddc-gis2/arcgis/rest/services/alt_basemaps/MapServer", "visibleLayers": null, "layers": [] }, { "id": "aerialmaps", "title": "aerialmaps", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "http://eddc-gis2/arcgis/rest/services/LIVEinternal/aerials/MapServer", "visibleLayers": null, "layers": [] }, { "id": "mainmap", "title": "mainmap", "opacity": 0.9, "minScale": 0, "maxScale": 0, "url": "http://eddc-gis2/arcgis/rest/services/test/emap2/MapServer", "visibleLayers": [], "layers": [] }, { "id": "graphicsLayer0", "minScale": 750, "maxScale": 0, "featureCollection": { "layers": [] } }, { "id": "usergraphics", "minScale": 0, "maxScale": 0, "featureCollection": { "layers": [{ "layerDefinition": { "name": "pointLayer", "geometryType": "esriGeometryPoint" }, "featureSet": { "geometryType": "esriGeometryPoint", "features": [{ "geometry": { "x": 314019.2829638273, "y": 87077.22170361727, "spatialReference": { "wkid": 27700 } }, "symbol": { "color": [0, 0, 0, 255], "size": 54, "angle": 0, "xoffset": 0, "yoffset": 0, "type": "esriSMS", "style": "esriSMSCircle", "outline": { "color": [255, 0, 0, 255], "width": 0.75, "type": "esriSLS", "style": "esriSLSSolid" } } }, { "geometry": { "x": 318090.52800466743, "y": 84938.78996499417, "spatialReference": { "wkid": 27700 } }, "symbol": { "color": [0, 0, 0, 255], "type": "esriTS", "horizontalAlignment": "left", "angle": 0, "xoffset": 0, "yoffset": 0, "text": "text last", "rotated": false, "kerning": true, "font": { "size": 54, "style": "normal", "variant": "normal", "decoration": "none", "weight": "normal", "family": "verdana" } } }] } }] } }, { "id": "graphicsLayer1", "minScale": 0, "maxScale": 0, "featureCollection": { "layers": [] } }, { "id": "graphicsLayer2", "minScale": 0, "maxScale": 0, "featureCollection": { "layers": [] } }, { "id": "map_graphics", "minScale": 0, "maxScale": 0, "featureCollection": { "layers": [] } }], "exportOptions": { "outputSize": [2125.98, 2362.2], "dpi": "96" }, "layoutOptions": { "titleText": "", "authorText": " ", "copyrightText": "Crown Copyright and database rights 2014 Ordnance Survey 100023746 ", "scaleBarOptions": { "metricUnit": "Kilometers", "metricLabel": "km", "nonMetricUnit": "Miles", "nonMetricLabel": "mi" }, "legendOptions": { "operationalLayers": [{ "id": "mainmap" }] } } }
{ "mapOptions": { "showAttribution": true, "extent": { "xmin": 283587.7543757293, "ymin": 78359, "xmax": 342600.2456242707, "ymax": 113602, "spatialReference": { "wkid": 27700 } }, "spatialReference": { "wkid": 27700 }, "scale": 155427.79855309209 }, "operationalLayers": [{ "id": "mainbasemaps", "title": "mainbasemaps", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "http://eddc-gis2/arcgis/rest/services/BaseMapOSNonTiled/MapServer", "visibleLayers": null, "layers": [] }, { "id": "altbasemaps", "title": "altbasemaps", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "http://eddc-gis2/arcgis/rest/services/alt_basemaps/MapServer", "visibleLayers": null, "layers": [] }, { "id": "aerialmaps", "title": "aerialmaps", "opacity": 1, "minScale": 0, "maxScale": 0, "url": "http://eddc-gis2/arcgis/rest/services/LIVEinternal/aerials/MapServer", "visibleLayers": null, "layers": [] }, { "id": "mainmap", "title": "mainmap", "opacity": 0.9, "minScale": 0, "maxScale": 0, "url": "http://eddc-gis2/arcgis/rest/services/test/emap2/MapServer", "visibleLayers": [], "layers": [] }, { "id": "graphicsLayer0", "minScale": 750, "maxScale": 0, "featureCollection": { "layers": [] } }, { "id": "usergraphics", "minScale": 0, "maxScale": 0, "featureCollection": { "layers": [{ "layerDefinition": { "name": "pointLayer", "geometryType": "esriGeometryPoint" }, "featureSet": { "geometryType": "esriGeometryPoint", "features": [{ "geometry": { "x": 312785.5723453909, "y": 85884.63477246207, "spatialReference": { "wkid": 27700 } }, "symbol": { "color": [0, 0, 0, 255], "type": "esriTS", "horizontalAlignment": "left", "angle": 0, "xoffset": 0, "yoffset": 0, "text": "text first", "rotated": false, "kerning": true, "font": { "size": 54, "style": "normal", "variant": "normal", "decoration": "none", "weight": "normal", "family": "verdana" } } }, { "geometry": { "x": 311140.62485414237, "y": 84239.68728121354, "spatialReference": { "wkid": 27700 } }, "symbol": { "color": [0, 0, 0, 255], "size": 54, "angle": 0, "xoffset": 0, "yoffset": 0, "type": "esriSMS", "style": "esriSMSCircle", "outline": { "color": [255, 0, 0, 255], "width": 0.75, "type": "esriSLS", "style": "esriSLSSolid" } } }] } }] } }, { "id": "graphicsLayer1", "minScale": 0, "maxScale": 0, "featureCollection": { "layers": [] } }, { "id": "graphicsLayer2", "minScale": 0, "maxScale": 0, "featureCollection": { "layers": [] } }, { "id": "map_graphics", "minScale": 0, "maxScale": 0, "featureCollection": { "layers": [] } }], "exportOptions": { "outputSize": [2125.98, 2362.2], "dpi": "96" }, "layoutOptions": { "titleText": "", "authorText": " ", "copyrightText": "Crown Copyright and database rights 2014 Ordnance Survey 100023746 ", "scaleBarOptions": { "metricUnit": "Kilometers", "metricLabel": "km", "nonMetricUnit": "Miles", "nonMetricLabel": "mi" }, "legendOptions": { "operationalLayers": [{ "id": "mainmap" }] } } }