Hello.
Sadly the developer who started this project has quit, and I am desperately trying to get up to speed.
All I want is something simple. Should be one of the most common functions in mapping - to add text inside a graphic as shown. (The map is generated, i put the number in there using paint for purposes of this post)
But as soon as I define a textsymbol, the program bombs. I don't even have to do anything with it, just the var declaration kills it. (See near the bottom of the code)
I have "required" esri/symbols/TextSymbol among others at the top of the script file.
The idea is to place the contents of the HCAD_NUM field from the shapefile near the middle of each plot. But I can't even get it to show a hard-coded "Hello world" anywhere on the screen.
Any help would be greatly appreciated.
require([
"esri/map",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/tasks/QueryTask",
"esri/tasks/query",
"dojo/dom",
"dojo/on",
"esri/layers/FeatureLayer",
"esri/Color",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/renderers/SimpleRenderer",
"esri/geometry/Extent",
"dojo/parser",
"esri/geometry/Circle",
"esri/units",
"esri/symbols/TextSymbol",
"esri/layers/LabelClass",
"esri/config",
"esri/graphic",
"esri/tasks/GeometryService",
"esri/tasks/BufferParameters",
"esri/toolbars/draw",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/Font",
"dojo/domReady!"],
function (Map, ArcGISDynamicMapServiceLayer, QueryTask,
Query, dom, on, FeatureLayer, Color, SimpleLineSymbol, SimpleFillSymbol, SimpleRenderer, Extent, parser, Circle, Units)
{
parser.parse();
//map = new Map("map");
map = new Map("map", {
//extent: bbox,
showLabels: true //very important that this must be set to true!
});
var baseLayer = new ArcGISDynamicMapServiceLayer("https://arcgis-ctngis-1263207624.us-west-2.elb.amazonaws.com/arcgis/rest/services/HCAD/CADDataAndPar...");
map.addLayer(baseLayer);
var countyLayer = new FeatureLayer("https://arcgis-ctngis-1263207624.us-west-2.elb.amazonaws.com/arcgis/rest/services/HCAD/CADDataAndPar...");
var outline = new SimpleLineSymbol("solid", new Color([255, 255, 255, 1]), 2);
var fill = new SimpleFillSymbol("solid", outline, new Color([255, 255, 0, 0.5]));
countyLayer.setRenderer(new SimpleRenderer(fill));
map.addLayer(countyLayer);
//Query the parcels layer for the subject property
queryTask = new QueryTask("https://arcgis-ctngis-1263207624.us-west-2.elb.amazonaws.com/arcgis/rest/services/HCAD/CADDataAndPar...");
query = new Query();
query.returnGeometry = true;
query.outFields = ["HCAD_NUM", "LocAddr"];
//Set up a callback for when the get details button is pressed.
function execute()
{
query.where = "HCAD_NUM = '" + dom.byId("hcad_num").value + "'";
queryTask.execute(query, foundSubject);
}
on(dom.byId("execute"), "click", execute);
//Set up a query for
function foundSubject(results)
{
var f = results.features;
circle = new Circle({center: f[0].geometry.getExtent().getCenter(), radius: dom.byId("distance").value, radiusUnit: Units.FEET});
//Execute a new query that searches for all properties around subject
var areaQuery = new Query();
areaQuery.geometry = circle.getExtent();
areaQuery.returnGeometry = true;
areaQuery.outFields = ["HCAD_NUM", "LocAddr"];
queryTask.execute(areaQuery, showResults);
}
function showResults(results)
{
var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 0, 0]), 1.0), new Color([255, 255, 255, 1])
);
var textSymbol = new TextSymbol("Hello, World");
map.graphics.clear();
var resultFeatures = results.features;
map.graphics.clear();
var resultFeatures = results.features;
//Zoom to parcel
var ex = esri.graphicsExtent(resultFeatures);
map.setExtent(ex);
for (var i = 0, il = resultFeatures.length; i < il; i++) {
var graphic = resultFeatures;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
var point = graphic.center;
var featureAttributes = graphic.attributes;
var resultItems = [];
for (var attr in featureAttributes) {
resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>");
}
resultItems.push("<br>");
}
dom.byId("info").innerHTML = resultItems.join("");
}
});