AnsweredAssumed Answered

Uncaught TypeError: Photos.setLabelingInfo is not a function

Question asked by iboates on Apr 30, 2017
Latest reply on May 2, 2017 by iboates

I am trying to create a web map with javascript, and I keep getting this error.  I have pretty much copy and pasted the code from this page: Labeling features on the client | ArcGIS API for JavaScript 3.20 

 

This is the code (I am clicking on the "code" button in the post interface but it refuses to format properly):

 

var map; <!-- Import der vordefinierten Module für die Variable "Map" -->
require([
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/TextSymbol",
"esri/renderers/SimpleRenderer",
"esri/layers/LabelClass",
"esri/Color",
"esri/geometry/Extent",
"esri/map",
"esri/dijit/BasemapToggle",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/FeatureLayer",
"esri/layers/RasterFunction",
"esri/layers/ImageParameters",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/dijit/Popup",
"esri/dijit/PopupTemplate",
"dojo/dom-construct",
"dojo/on",
"esri/InfoTemplate",
"dojo/dom",
"dojo/query",
"dojo/domReady!",
"esri/dijit/Legend",
"dojo/_base/array",
"dojo/parser",
"dijit/form/HorizontalSlider",
"esri/dijit/Scalebar"],
function(SimpleLineSymbol,
SimpleFillSymbol,
TextSymbol,
SimpleRenderer,
LabelClass,
Color,
Extent,
Map,
BasemapToggle,
ArcGISDynamicMapServiceLayer,
FeatureLayer,
RasterFunction,
ImageParameters,
ArcGISTiledMapServiceLayer,
Popup,
PopupTemplate,
DomConstruct,
on,
InfoTemplate,
dom,
query,
ready,
Legend,
arrayUtils,
parser,
HorizontalSlider,
Scalebar)


{
var extent = new Extent({"xmin":2054005.395500005 , "ymin":6188618.186554961, "xmax":2079286.521715342, "ymax":6203773.949341377,"spatialReference": {"wkid": 3857}});
var popup = Popup({ <!-- Definition Popup -->
titleInBody: false
},DomConstruct.create("div"));



map = new Map("mapDiv", {
"extent": extent,
basemap:"topo",
infoWindow: popup, <!-- Füllen des Info Windows -->
showLabels: true
});

var Scalebar = new Scalebar({
map: map,
scalebarUnit: "dual",
attachTo: "bottom-left"

});
document.getElementsByClassName("scalebar_bottom-left esriScalebar")[0].style.bottom= "60px";
document.getElementsByClassName("scalebar_bottom-left esriScalebar")[0].style.left= "25px";

document.getElementsByClassName("esriScalebarLabel")[0].style.color ="black";
document.getElementsByClassName("esriScalebarLabel")[1].style.color ="black";

document.getElementsByClassName("esriScalebarLineLabel")[0].style.color ="black";
document.getElementsByClassName("esriScalebarLineLabel")[1].style.color ="black";

document.getElementsByClassName("esriScalebarLine")[1].style.borderColor="black"
document.getElementsByClassName("esriScalebarMetricLine")[0].style.borderColor="black"

document.getElementsByClassName("esriScalebarLabel")[0].style.color = "black";
document.getElementsByClassName("esriScalebarLabel")[1].style.color = "black";


var toggle = new BasemapToggle({
map: map,
basemap: "satellite"
}, "BasemapToggle");
toggle.startup();

<!-- web services begin here -->

var Photos = new FeatureLayer("https://www.imm.hs-karlsruhe.de/devsrv/rest/services/Gr2_Slvk2017/Gr2_P_VP_2_Photos/MapServer/0", {
id: "Photos",
outFields: ["*"],
visible: true
});

var photosColor = new Color("#ffffff");
var photosLine = new SimpleLineSymbol("solid", photosColor, 1.5);
var photosSymbol = new SimpleFillSymbol("solid", photosLine, null);
var photosRenderer = new SimpleRenderer(photosSymbol);

var json = {
"labelExpressionInfo": {"value": "{azimuth}"}
};

var photosLabel = new TextSymbol().setColor(photosColor);
photosLabel.font.setSize("14pt");
photosLabel.font.setFamily("arial");

var labelClass = new LabelClass(json);
labelClass.symbol = photosLabel; // symbol also can be set in LabelClass' json
Photos.setLabelingInfo([ labelClass ]);

map.addLayer(Photos);

})

Outcomes