Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arcgisOnlineProvider attribute 'apikey' doesn't exist #318

Closed
hman1148 opened this issue Jul 15, 2024 · 4 comments
Closed

arcgisOnlineProvider attribute 'apikey' doesn't exist #318

hman1148 opened this issue Jul 15, 2024 · 4 comments

Comments

@hman1148
Copy link

Describe the bug

After importing the esri-leaflet-geocoder library into my project, I attempted to use the esri.GeoCoding namespace in my project to access arcgisOnlineProvider. When I attempted to feed in my apikey to the documented apikey attribute, I get an error that reads:

"Object literal may only specify known properties, and 'apikey' does not exist in type 'ArcgisOnlineProviderOptions"

To my understanding, I should have access to the apikey attribute according to the documentation located here under the "Providers" category:
https://developers.arcgis.com/esri-leaflet/api-reference/controls/geosearch/

I could be misunderstanding how this provider works. Ultimately with my code I want to feed in an API Key that I have in my project to the provider. I am using a regular import statement like such because esri-leaflet-geocoder doesn't have an export type, or object in the source code:

import 'sri-leaflet-geocoder'

I don't know if this is a bug with the library or if this is a lack of understanding of how providers work on my part. Thanks!

Reproduction

1: npm i --save-dev @types/esri-leaflet-geocoder
2. Add in the library via import 'esri-leaflet-geocoding'
3. Attempt to use the namespace as directed by the source library esri.Geocoding.arcgisOnlineProvider({ apikey: "" )};
4. You will receive the error

Logs

No response

System Info

Leaflet Version: 2.13.1
esri-geocoder: 3.1.4

Additional Information

No response

@shakyad
Copy link

shakyad commented Aug 27, 2024

Same issue here. Just following the documentation and the 'apikey' does not exist. Using geocoder 3.1.4, leaflet: v1.9.4, and esri-leaflet-vector: v4.2.4

@gavinr-maps gavinr-maps transferred this issue from Esri/esri-leaflet Aug 27, 2024
@gavinr-maps
Copy link
Contributor

gavinr-maps commented Aug 27, 2024

Try to import using this style:

import { geosearch, arcgisOnlineProvider } from "esri-leaflet-geocoder";

It's working for me in the react demo here (see this place in the code specifically).

@shakyad
Copy link

shakyad commented Aug 27, 2024

It worked for me with import statement.

import * as ELG from 'esri-leaflet-geocoder';

I then followed the documentation code and it works now. I had imported @types for geocoder but had to delete it. not sure there was anything to do with it.

    const searchControl = ELG.geosearch({
      position: 'topright',
      placeholder: 'Type the place or address to search.',
      useMapBounds: false,
      providers: [
        ELG.arcgisOnlineProvider({
          apikey: apiKey,
        }),
      ],
    }).addTo(this.map);

    var results = L.layerGroup().addTo(this.map);

    searchControl.on('results', function (data) {
      results.clearLayers();
      for (var i = data.results.length - 1; i >= 0; i--) {
        results.addLayer(L.marker(data.results[i].latlng));
      }
    });

@gavinr-maps
Copy link
Contributor

I created #319 to cover the possible TypeScript types issue. I'm going to close this issue. @hman1148 if your issue is not resolved using the example from #318 (comment), please open a separate issue. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants