Use the autocomplete widget without a map
This example uses the goong-geocoder control to enable users to search for places without an associated map view.
No map appears in this example, but you can use the geocoder control to search for a place, and the control will return place results from the Goong Places API.
Search for a place like san bay noi bai to test the geocoder and see results.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Use the autocomplete widget without a map</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://cdn.jsdelivr.net/npm/@goongmaps/goong-js@1.0.9/dist/goong-js.js"></script>
<link href="https://cdn.jsdelivr.net/npm/@goongmaps/goong-js@1.0.9/dist/goong-js.css" rel="stylesheet" />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<!-- Load the `goong-geocoder` plugin. -->
<script src="https://cdn.jsdelivr.net/npm/@goongmaps/goong-geocoder/dist/goong-geocoder.min.js"></script>
<link
href="https://cdn.jsdelivr.net/npm/@goongmaps/goong-geocoder/dist/goong-geocoder.css"
rel="stylesheet"
type="text/css"
/>
<!-- Promise polyfill script is required -->
<!-- to use Goong Geocoder in IE 11. -->
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js"></script>
<style>
#geocoder {
z-index: 1;
margin: 20px;
}
.goongjs-ctrl-geocoder {
min-width: 100%;
}
</style>
<div id="geocoder"></div>
<pre id="result"></pre>
<script>
var geocoder = new GoongGeocoder({
accessToken: '{Your_API_Key}'
});
geocoder.addTo('#geocoder');
// Get the geocoder results container.
var results = document.getElementById('result');
// Add geocoder result to container.
geocoder.on('result', function (e) {
results.innerText = JSON.stringify(e.result, null, 2);
});
// Clear results container when search is cleared.
geocoder.on('clear', function () {
results.innerText = '';
});
</script>
</body>
</html>