Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
Query esri search widget

this is the sample search widget in arcGIS, I want to override the search function, that the only thing that can be searched is the data in my query and it will appear just like in the picture

const [searchData, setSearchData] = useState(null);
const fetchSearchLocation = async (name) => {
const { data } = await client.query({  
  query: SEARCH_LOCATION,
  variables: {
    name: name    
  },
})
setSearchData(data);

return data;
};

  useEffect(() => {
    location();
  }, []);

 const location = () => {
    if (mapDiv.current) {
      esriConfig.apiKey = "sample api key";
      const map = new Map({
        basemap: 'arcgis-light-gray',
      });
      const view = new MapView({
        center: [123.5504, 12.3574], // Longitude, latitude
        container: mapDiv.current,
        map: map,
        zoom: 2, // Zoom level
      });
      const searchWidget = new Search({
        view: view,
        sources: [customSearchSource],
        includeDefaultSources: false
      });
  
      view.ui.add(searchWidget, { position: "top-left", index: 0 });
      view
        .when((r) => {})
        .then(() => {
          mapDiv.current = view;
          fetchData();
        });
    }
  };

  const searchDataLocation = new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log("searchData: ", searchData)
        resolve(searchData); //test_data = Your data.
    }, 1000);
  });

  const customSearchSource = new SearchSource({
    placeholder: 'Search',
    getSuggestions: (params) => {
       fetchSearchLocation(params.suggestTerm)
       console.log("searchData2: ", searchData)
        return searchDataLocation.then((data) => {
        console.log("datas: ", data) // the result is null.
      })
   ....

enter image description here

resource

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html

How to put queries in ArcGIS esri search?

note: this is edited question

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda