Get started with places.js CDN
MIT licensed
Places.js is a lightweight library for working with geolocation and maps in JS.
Tags:- algolia
- geo
- search
- place
- input
Stable version
Copied!
How to start using places.js CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with places.js CDN - cdnhub.io</title>
<style>
#map {
height: 400px;
width: 100%;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places"></script>
<script src="https://cdn.cdnhub.io/places.js/1.19.0/places.min.js"></script>
</head>
<body>
<div id="map"></div>
<script>
const input = document.createElement('input');
input.type = 'text';
input.id = 'search';
document.body.appendChild(input);
const map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 40.7128, lng: -74.0060 },
zoom: 12,
});
const autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindToMap(map);
const places = new Places.Autocomplete(input);
places.setTypes(['address']);
places.addListener('place_changed', () => {
const place = autocomplete.getPlace();
if (place.geometry) {
map.setCenter(place.geometry.location);
}
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
All versions
0.0.1
0.0.10
0.0.11
0.0.12
0.0.13
0.0.14
0.0.15
0.0.16
0.0.17
0.0.18
0.0.2
0.0.3
0.0.4
0.0.5
0.0.6
0.0.7
0.0.8
0.0.9
0.19.0
0.20.0
0.21.0
0.22.0
0.23.0
0.23.1
0.24.0
0.25.0
0.26.0
0.27.0
0.28.0
0.29.0
0.30.0
0.31.0
0.32.0
0.33.0
1.0.0
1.0.1
1.0.2
1.1.2
1.1.3
1.1.4
1.1.5
1.1.6
1.1.7
1.10.0
1.11.0
1.12.0
1.13.0
1.14.0
1.15.0
1.15.1
1.15.2
1.15.3
1.15.4
1.15.5
1.16.1
1.16.2
1.16.3
1.16.4
1.16.5
1.16.6
1.17.0
1.17.1
1.18.1
1.18.2
*** 1.19.0
1.2.0
1.2.1
1.3.0
1.3.1
1.3.2
1.3.3
1.3.4
1.4.0
1.4.1
1.4.10
1.4.11
1.4.12
1.4.13
1.4.14
1.4.15
1.4.17
1.4.18
1.4.2
1.4.3
1.4.4
1.4.5
1.4.6
1.4.7
1.4.8
1.4.9
1.5.0
1.6.0
1.7.2
1.7.3
1.8.0
1.9.0
1.9.1