Religious organizations- Places TextSearch
HTML
<script src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<button onclick="performSearch()">Search</button>
<div id="placename"></div>
<div id="map_canvas" class="gmap border_box"></div>
<script src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
CSS
.gmap {
width:100%;
height:250px;
border: 1px solid #4D2722;
}
.border_box {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
JavaScript
var map;
var service;
function initialize() {
//set up google map
map = new google.maps.Map(document.getElementById('map_canvas'), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(48.8629,2.3284),
zoom: 10
});
//initialize places service to perform TextSearch
service = new google.maps.places.PlacesService(map);
}
function performSearch() {
var request = {
location: new google.maps.LatLng(48.8629,2.3284),
radius: '100',
types:['bar', 'night_club']
};
service.nearbySearch(request, textsearchcallback);
return false;
}
function textsearchcallback(results, status) {
console.log('results:', results)
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (p in results) {
$('#placename').append(JSON.stringify(results[p].name) + '<br />');
//For More Detail Use This:
//$('#placename').append(JSON.stringify(results[p]) + '<br />');
}
} else {
alert("ERROR");
}
}
$(function(){
initialize();
});