Get started with openlocationcode CDN
Apache-2.0 licensed
Library: encodes/decodes geo coordinates to compact, human-readable formats
Tags:- javascript
- library
- openlocationcode
Stable version
Copied!
How to start using openlocationcode CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with openlocationcode CDN - cdnhub.io</title>
<script src="https://cdn.cdnhub.io/openlocationcode/1.0.4/openlocationcode.min.js"></script>
</head>
<body>
<button id="decode">Decode OpenLocationCode</button>
<p id="result"></p>
<script>
const decodeButton = document.getElementById('decode');
const resultElement = document.getElementById('result');
decodeButton.addEventListener('click', () => {
const openLocationCode = '54.008968,32.372157,15';
const decodedLocation = ol.proj.fromLonLat(ol.coordinate.decode(openLocationCode), 'EPSG:4326');
resultElement.textContent = `Decoded location: ${decodedLocation[0]}, ${decodedLocation[1]}`;
});
// Import OpenLayers library for coordinate conversion
import 'https://cdn.jsdelivr.net/npm/ol@6.4.4/build/ol.js';
</script>
</body>
</html>
Copied!
Copied!