Closed gisnovice closed 7 years ago
I have a file config/search.js
where I put all this:
define([
'esri/tasks/locator',
'esri/layers/FeatureLayer',
'esri/InfoTemplate',
'dojo/has'
], function (Locator, FeatureLayer, InfoTemplate, has) {
return {
map: true,
mapRightClickMenu: true,
enableInfoWindow: true,
enableButtonMode: has('mobile') ? false: true,
expanded: true,
allPlaceholder: 'Find an address',
sources: [{
placeholder: 'Find an address',
locator: new Locator('//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer'),
singleLineFieldName: 'SingleLine',
outFields: ['Addr_type'],
name: 'Property Search',
localSearchOptions: {
minScale: 300000,
distance: 50000
}
}, {
featureLayer: new FeatureLayer('/arcgis/rest/services/internal/assets/MapServer/12', {
outFields: ['cid', 'Shape', 'OBJECTID']
}),
outFields: ['cid'],
searchFields: ['cid'],
suggestionTemplate: 'Structure Number: ${cid}',
exactMatch: false,
name: 'Storm Structure ID',
placeholder: 'Structure ID',
maxResults: 6,
maxSuggestions: 6,
enableSuggestions: true,
minCharacters: 0,
localSearchOptions: {distance: 5000},
infoTemplate: new InfoTemplate('Structure Found', 'ID: ${cid}')
},
//.........
and in viewer.js my search widget options: 'config/search'
@roemhildtg uses the same approach I take for my applications.
@roemhildtg Thanks for code, but now for the search bar I have the default suggestions, but it does not geolocate the information I enter.
viewer.js/search widget
search: {
include: true,
type: has('phone') ? 'titlePane' : 'ui',
path: 'esri/dijit/Search',
placeAt: has('phone') ? null : 'top-center',
title: i18n.viewer.widgets.search,
iconClass: 'fa-search',
position: 0,
options: 'config/search'
},
and I modified the seach.js, with esri/dijit/Search
and it seamed to solve what I needed.
define([
'esri/tasks/locator',
'esri/dijit/Search',
'esri/layers/FeatureLayer',
'esri/InfoTemplate',
'dojo/has'
], function (Locator, Search, FeatureLayer, InfoTemplate, has) {
return {
map: true,
mapRightClickMenu: true,
enableInfoWindow: true,
enableButtonMode: has('mobile') ? false: true,
expanded: true,
allPlaceholder: 'Find an address or APN',
sources: [{
placeholder: 'Find an address',
locator: new Locator('http://gis.ci.oceanside.ca.us/gis/rest/services/AddressLocator_Composite2016/GeocodeServer'),
singleLineFieldName: 'SingleLine',
outFields: ['Loc_name'],
name: 'Address Search',
localSearchOptions: {
minScale: 300000,
distance: 50000
}
}, {
featureLayer: new FeatureLayer('http://gis.ci.oceanside.ca.us/gis/rest/services/WebService/Planning/MapServer/3'),
searchFields: ["APN"],
displayField: "APN",
exactMatch: false,
name: "Assessor's Parcel Number",
outFields: ['*'],
placeholder: 'APN - ex 1470950400',
maxResults: 6,
maxSuggestions: 6,
enableSuggestions: true,
minCharacters: 0,
localSearchOptions: { distance: 5000 },
infoTemplate: new InfoTemplate('APNs Found', 'ID: ${APN}')
}]
}
})
If I am try to put a featureLayer into the search bar would I do the following for viewer.js?