Google Search Places API with Map
HTML
<script src="http://maps.google.com/maps/api/js?key=AIzaSyBy2VY1e11qs-60Ul6aYT5klWYRI1K3RB0&libraries=places"></script>
<input id="searchTextField" type="text" size="50">
<div id="map"></div>
CSS
body {
font:14px sans-serif;
}
input {
margin: 0.6em 0.6em 0;
width:398px;
}
#map{
height: 400px;
width: 100%;
margin: 0.6em;
}
JavaScript
$(function(){
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -33.866745, lng: 151.209386},
zoom: 13
});
var request = {
placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4'
};
service = new google.maps.places.PlacesService(map);
service.getDetails(request, callback);
function callback(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
createPhotoMarker(place);
}
}
function createPhotoMarker(place) {
var photos = place.photos;
if (!photos) {
return;
}
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location,
title: place.name,
icon: photos[0].getUrl({'maxWidth': 35, 'maxHeight': 35})
});
}
});