Display Near by places with Google Places API

17 May
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Google Maps JavaScript API v3 Example: Place Search</title>
<script type="text/javascript" src=""></script>

<style type="text/css">
#map {
height: 400px;
width: 600px;
border: 1px solid #333;
margin-top: 0.6em;

<script type="text/javascript">
var map;
var infowindow;

function initialize() {
var pyrmont = new google.maps.LatLng(-33.8665433, 151.1956316);

map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: pyrmont,
zoom: 15

var request = {
location: pyrmont,
radius: 500,
types: ['store']
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);, callback);

function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {

function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location

google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(;, this);

google.maps.event.addDomListener(window, 'load', initialize);
<div id="map"></div>
<div id="text">
var request = {
location: new google.maps.LatLng(-33.8665433, 151.1956316),
radius: 500,
types: ['store']



Posted by on May 17, 2012 in Geo Programming, JavaScript


Tags: ,

4 responses to “Display Near by places with Google Places API

  1. yuri boyka

    September 20, 2017 at 4:33 pm

    Code is working very well and it is working as per my requirement, but issue is that I want to dynamic LAT,LONG in Php and implement on WordPress.

    • Rajitha

      September 20, 2017 at 5:45 pm

      Hi, code can be ported into WordPress.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: