Closed JudyZhou closed 7 years ago
@JudyZhou You can use the Esri Search widget with CMV just as you have done with the WAB. The Esri Geocoder widget has been deprecated by Esri so the Search widget is the preferred option. We have switched to the search widget in CMV.
@tmcgee thank you for help! does CMV has search widget already? where can I download it?
@JudyZhou I provided a link in my previous response to the line in the demo viewer.js where the Esri search widget is included. It is not a CMV widget. No downloading required.
I think there is actually a bug with cmv and loading feature layer searches. Adding feature layer searches doesn't work in cmv due to the widget loader using lang.clone
on the widget options.
This documentation uses the FeatureLayer
constructor in the source options. But the clone
function cannot clone a FeatureLayer object, for example the following throws an error:
lang.clone(new FeatureLayer('url'))
This can be reproduced in cmv using the config:
search: {
include: true,
type: 'domNode',
path: 'esri/dijit/Search',
srcNodeRef: 'geocoderButton',
options: {
map: true,
mapRightClickMenu: true,
enableInfoWindow: true,
enableButtonMode: true,
expanded: false,
sources: [{
featureLayer: new FeatureLayer('/arcgis/rest/services/internal/assets/MapServer/12', {
outFields: ['cid', 'Shape', 'OBJECTID']
}),
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}
}]
}
},
@tmcgee is that lang.clone
needed on the widget loader?
@roemhildtg I don't have a problem including feature layers in the Esri Search widget and have used it often for clients. I will compare the example you provided above with one of my working versions and see if I can identify the difference.
@roemhildtg I think the difference in our approaches may be that I do not include the search widget's options within viewer.js
but within a separate file search.js
. As a by-product my approach, the feature layer(s) in the widget's options do not get cloned.
As to why lang.clone
is used with the widget config, that line pre-dates my involvement with the CMV project. I think we can just remove it because it is problematic for this Esri widget and potentially others - specifically those widgets that include Esri modules within their config options. As we've seen elsewhere, some of the Esri modules don't handle cloning well.
@DavidSpriggs do you recall the original need for lang.clone
in this line and any objections to not cloning the config?
I see, that would make sense since if you pass a string as the widget options, lang.clone won't be used on the actual options object.
Correct
I don't think the lang.clone
is necessary. I've taken it out on my end and things appear to be in working order. We should add this enhancement to the widget mixin to allow feature layers in the options properties.
closed in https://github.com/cmv/cmv-app/pull/736
Hello, can I add my own GeocodeServer to the search widget? I am trying for the search widget to also recognize APNs, or would it only be suited for the Find 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: {
map: true,
visible: true,
enableInfoWindow: true,
enableButtonMode: has('phone') ? false : true,
expanded: has('phone') ? true : false,
expanded: true,
defaultSource: 'http://gis.ci.oceanside.ca.us/gis/rest/services/AddressLocator_Composite2016/GeocodeServer'
}
},
I need to add search features to Geocoder. I have done this in ESRI Search widget in web AppBuilder before. this time I added code into Geocoder.js like this, but search result return not found. Or is available a search widget including data search and geocoder? Please help!: