AnsweredAssumed Answered

typescript files error on search widget

Question asked by sky12james on May 2, 2018

I try to write a simple typescript file to have "search widget" based on the sample here:

ArcGIS API for JavaScript Sandbox  But keep getting error message.  I am very new to typescript.  Can you help me take a look?  Thank you.

 

import EsriMap = require("esri/Map");
import MapView = require("esri/views/MapView");
import Search = require("esri/widgets/Search");
//Esri basemap
const map = new EsriMap({
basemap: "streets"
});

 

const view = new MapView({
map: map,
container: "viewDiv",
center: [-97, 38], // lon, lat
scale: 10000000
});

const searchWidget = new Search({
view: view,
allPlaceholder: "District or Senator",
sources: [{
featureLayer: {
popupTemplate: { // autocasts as new PopupTemplate()
title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
overwriteActions: true
}
},
searchFields: ["DISTRICTID"],
displayField: "DISTRICTID",
exactMatch: false,
outFields: ["DISTRICTID", "NAME", "PARTY"],
name: "Congressional Districts",
placeholder: "example: 3708",
}, {
featureLayer: {
popupTemplate: { // autocasts as new PopupTemplate()
title: "<a href={Web_Page} target='_blank'> {Name}</a>, ({Party}-{State}) ",
overwriteActions: true
}
},
searchFields: ["Name", "Party"],
suggestionTemplate: "{Name}, Party: {Party}",
exactMatch: false,
outFields: ["*"],
placeholder: "example: Casey",
name: "Senators",
zoomScale: 500000
}]
});

// Add the search widget to the top left corner of the view
view.ui.add(searchWidget, {
position: "top-right"
});

Attachments

Outcomes