Last active
April 24, 2023 09:07
-
-
Save axcellence/4152302da4c28ef4826629d476b3e1af to your computer and use it in GitHub Desktop.
Woosmap MultiSearch API implementation comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Brew Details call | |
const getSearchDetails = async suggestion => { | |
const details = await autocompleteService.detailsMulti({ | |
id: suggestion.id, | |
api: suggestion.api, | |
}) | |
return details | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Brew MultiSearch config | |
const autocompleteService = window.woosmap.multisearch({ | |
apiOrder: ["localities", "store", "address", "places"], | |
debounceTime: 100, | |
store: { | |
key: conf.woosmapLoadOptions.publicKey, | |
fallbackBreakpoint: 0.5, | |
}, | |
localities: { | |
key: conf.woosmapLoadOptions.publicKey, | |
fallbackBreakpoint: 0.4, | |
params: { | |
components: { | |
country: ["GB"], | |
language: "en", | |
types: ["locality", "country", "postal_code"], | |
}, | |
}, | |
}, | |
address: { | |
key: conf.woosmapLoadOptions.publicKey, | |
fallbackBreakpoint: 0.5, | |
minInputLength: 5, | |
params: { | |
components: { country: ["GBR"] }, | |
language: "en", | |
}, | |
}, | |
places: { | |
key: conf.woosmapLoadOptions.publicKey, | |
fallbackBreakpoint: 1, | |
minInputLength: 10, | |
}, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Woosmap Details call | |
// source: https://codesandbox.io/s/multisearch-demo-fallbackbreakpointfalse-43rz9?from-embed=&file=/src/index.js:2578-2878 | |
try { | |
const result = await multisearchInstance.detailsMulti({ id, api }); | |
showMarker(result); | |
document.getElementById("autocomplete").value = | |
result.name || result.formatted_address; | |
console.log("details", result); | |
} catch (error) { | |
console.log(error); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Woosmap MultiSearch usage | |
// source: https://codesandbox.io/s/multisearch-demo-fallbackbreakpointfalse-43rz9?from-embed=&file=/src/multisearch-config.js | |
const multisearch = window.woosmap.multisearch({ | |
apiOrder: ["store", "localities", "address", "places"], | |
debounceTime: 100, | |
localities: { | |
key: "woos-03ae8b61-46a4-3a8c-aa26-7c970087d5ba", | |
fallbackBreakpoint: 0.4, | |
params: { | |
components: { | |
country: ["gb"] | |
}, | |
language: "gb", | |
types: [] | |
} | |
}, | |
address: { | |
key: "woos-03ae8b61-46a4-3a8c-aa26-7c970087d5ba", | |
fallbackBreakpoint: 0.5, | |
minInputLength: 5, | |
params: { | |
components: { | |
country: ["gb"] | |
}, | |
language: "gb" | |
} | |
}, | |
store: { | |
key: "woos-03ae8b61-46a4-3a8c-aa26-7c970087d5ba", | |
fallbackBreakpoint: false, | |
params: { | |
query: "type:bose_store" | |
} | |
}, | |
places: { | |
key: "AIzaSyAAFBEYl6VnHSyllckphcRWzJlomsoXosA", | |
fallbackBreakpoint: 1, | |
minInputLength: 10, | |
params: { | |
components: { | |
country: ["gb"] | |
} | |
} | |
} | |
}); | |
export default multisearch; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment