Getting errors while implementing Find Places in the application

424
3
04-23-2021 08:15 AM
SahilBansal
New Contributor II

Hi,

I am getting the below error s while implementing find places functionality in the application.

No overload matches this call.

const select = document.createElement('select', '');

Argument of type '{ location: any; categories: string[]; maxLocations: number; outFields: string[]; }' is not assignable to parameter of type 'LocatorAddressToLocationsParams'.

 

PFB the code snippet.

 

const findPlaces = (categorystringptany=> {
    locator
      .addressToLocations({
        location: pt,
        categories: [category],
        maxLocations: 25,
        outFields: ['Place_addr''PlaceName']
      })
      .then((results=> {
        view.popup.close();
        view.graphics.removeAll();

        results.forEach((result=> {
          view.graphics.add(
            new Graphic({
              attributes: result.attributes// Data attributes returned
              geometry: result.location// Point returned
              symbol: new SimpleMarkerSymbol({
                type: 'simple-marker',
                color: '#000000',
                size: '12px',
                outline: {
                  color: '#ffffff',
                  width: '2px'
                }
              }),

              popupTemplate: {
                title: '{PlaceName}'// Data attribute names
                content: '{Place_addr}'
              }
            })
          );
        });
      });
  };
0 Kudos
3 Replies
ReneRubalcava
Frequent Contributor II

ah, the TypeScript typing wants an `address` field, but that's not actually required for that method.

We can update the typings for 4.20, for now you can work around by casting the param object as any, or maybe adding address: null, to the param. 

0 Kudos
SahilBansal
New Contributor II

Hi, 

Thanks for the solution but still this error exits (No overload matches this call).

error TS2769: No overload matches this call.
Overload 1 of 3, '(tagName: "select", options?: ElementCreationOptions | undefined): HTMLSelectElement', gave the following error.
Argument of type '""' is not assignable to parameter of type 'ElementCreationOptions | undefined'.
Overload 2 of 3, '(tagName: "listing" | "xmp", options?: ElementCreationOptions | undefined): HTMLPreElement', gave the following error.
Argument of type '"select"' is not assignable to parameter of type '"listing" | "xmp"'.
Overload 3 of 3, '(tagName: string, options?: ElementCreationOptions | undefined): HTMLElement', gave the following error.
Argument of type '""' is not assignable to parameter of type 'ElementCreationOptions | undefined'.

and it is coming in the (document.createElement('select', '') ) code snippet. Moreover PFB the full code snippet.

 const select = document.createElement('select''');
    select.setAttribute('class''esri-widget esri-select');
    select.setAttribute(
      'style',
      'width: 175px; font-family: \'Avenir Next W00\'; font-size: 1em');
0 Kudos
ReneRubalcava
Frequent Contributor II

You don't need the second argument for createElement unless you are creating a custom element web component.

https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

That's a DOM typing issue, remove the second argument and should be fine.

0 Kudos