Select to view content in your preferred language

missing simple renderer/resources in local api build using bower/dojo

510
0
01-09-2018 02:34 PM
deleted-user-NafuMc_hs6Px
New Contributor

Summary: specific feature layer/simple renderer will work using the esri-hosted version of the api but not using local copy (all other feature layers work)

To replicate the issue, go to https://dojo-arcmap.byu.edu/ then More > AED Locations, view the console error, then try the same steps using the esri-hosted api https://arcmap.byu.edu/ to see it work there

The error listed says "Uncaught (in promise) TypeError: i.getSymbol is not a function" the files referenced are not helpful in identifying the error as variables are fairly ambiguous but on the surface it seems like an issue with rendering the symbol for the featureLayer

I thought it may be the aed.png for the simplerenderer is referenced in the wrong location, but put in a black simple-marker dot does not solve the issue.

Has someone had a similar error? Is this an issue with the build profile someone can identify for me? Any insight would be greatly appreciated. I'll attach the full main.js and the build profile

the relevant code for the featurelayer:

function toggleAEDs() {
removeLayers();
require([
"esri/request",
"esri/geometry/Point",
"esri/widgets/Legend",
"esri/config",
"esri/renderers/SimpleRenderer",
"dojo/domReady!"
], function(esriRequest, Point, Legend, esriConfig, SimpleRenderer) {
var aedurl = "https://risk.byu.edu/ws/aedfeed.php";
esriConfig.request.corsEnabledServers.push("https://risk.byu.edu/");
getData().then(createGraphics). // then send it to the createGraphics() method
then(createLayer). // when graphics are created, create the layer
otherwise(errback);
//attempt to access the aedlive feed. if not, return the local aedfeed.json
function getData() {
return esriRequest(aedurl).then(function(response) {
//console.log(response);
return response;
}).otherwise(function(error) {
console.log('request failed, grabbing local feed');
return esriRequest("scripts/aedfeed.json", {responseType: "json"});
});
}
function createGraphics(response) {
// raw GeoJSON data
var geoJson = response.data;
// Create an array of Graphics from each GeoJSON feature
return geoJson.features.map(function(feature, i) {
return {
geometry: new Point({x: feature.geometry.coordinates[0], y: feature.geometry.coordinates[1]}),
// select only the attributes you care about
attributes: {
ObjectID: i,
building: feature.properties.building,
room: feature.properties.room,
location: feature.properties.location,
picture: feature.properties.picture
}
};
});
}
function createLayer(graphics) {

var fields = [
{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
}, {
name: "building",
alias: "building",
type: "string"
}, {
name: "room",
alias: "room",
type: "string"
}, {
name: "location",
alias: "location",
type: "string"
}, {
name: "picture",
alias: "picture",
type: "string"
}
];
var template = {
title: "AED #{ObjectID}",
content: "<img src='{picture}' height='320' width='240'/><div class='popupText'>{building} room {room} {location} </div>"
};
var featureLayer = new FeatureLayer({
source: graphics, // autocast as an array of esri/Graphic
// create an instance of esri/layers/support/Field for each field object
fields: fields, // This is required when creating a layer from Graphics
objectIdField: "ObjectID", // This must be defined when creating a layer from Graphics
renderer: {
type: "simple", // autocasts as new SimpleRenderer()
symbol: {
type: "picture-marker", // autocasts as new SimpleMarkerSymbol()
url: "aed.png",
width: "30px",
height: "56px"
}
},
spatialReference: {
wkid: 4326
},
popupTemplate: template,
geometryType: "point", // Must be set when creating a layer from Graphics
});

map.add(featureLayer);
featureLayerIDSet.push(featureLayer.id);
return featureLayer;
}
function createLegend(layer) {}
function errback(error) {
console.error("Creating failed. ", error);
}
});
}

0 Kudos
0 Replies