Skip to content

Custom location provider, need more documentation. #39

@Duoquote

Description

@Duoquote

As there is no Google Location provider #8 I am trying to add my own, but I don't know what to return back exactly. What I think returning would work is not working.

Current state is:

<Search
  position = "topleft"
  inputPlaceholder = "Arama yap"
  customProvider = {
    {
      search: async (inputVal) => {
        return new Promise((res, rej) => {
          axios.get("https://maps.googleapis.com/maps/api/place/findplacefromtext/json", {
              params: {
                key: GAPI_KEY,
                fields: "formatted_address,name,geometry",
                inputtype: "textquery",
                input: inputVal
              }
            })
            .then((response) => {
              console.log(response);
              res(response.data.candidates.map(data => {
                return {
                  info: {
                    bounds: data.geometry.viewport,
                    latitude: data.geometry.location.lat,
                    longitude: data.geometry.location.lng,
                    name: data.formatted_address,
                  },
                  raw: response,
                }
              }))
            })
        })
      }
    }
  }
  showMarker = {
    false
  }
  // zoom={7}
  closeResultsOnClick = {
    true
  }
  openSearchOnLoad = {
    false
  }
\>

Resolving the promise works as searching... text goes away but I can't get it work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions