typescript files error on search widget

577
1
05-02-2018 05:33 AM
jamesa
by
New Contributor III

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"
});
0 Kudos
1 Reply
PhilLarkin1
Occasional Contributor III

Hi James-

I am experiencing the same issue. See my comments here: TypeScript error when creating Search Widget (JS 4.8) 

Did you find a resolution? 

0 Kudos