TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Google Map with Address by using PHP
Vinod Verma
Oct 10
2014
Code
2.5
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<title>Untitled Document</title>
<style type=
"text/css"
>
html, body, #map-canvas { height: 100%; margin: 0; }
</style>
<script type=
"text/javascript"
src=
"http://maps.google.com/maps/api/js?sensor=false"
></script>
<script type=
"text/javascript"
>
var
geocoder;
var
map;
var
address =
"<?php echo "
Sector 60 Noida
"; ?>"
;
function
initialize()
{
geocoder =
new
google.maps.Geocoder();
var
latlng =
new
google.maps.LatLng(-34.397, 150.644);
var
myOptions = {
zoom: 15, center: latlng, mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map =
new
google.maps.Map(document.getElementById(
"map-canvas"
), myOptions);
if
(geocoder)
{
geocoder.geocode( {
'address'
: address},
function
(results, status)
{
if
(status == google.maps.GeocoderStatus.OK)
{
if
(status != google.maps.GeocoderStatus.ZERO_RESULTS)
{
map.setCenter(results[0].geometry.location);
var
infowindow =
new
google.maps.InfoWindow(
{ content:
'<b>'
+address+
'</b>'
,
size:
new
google.maps.Size(150,50)
});
var
marker =
new
google.maps.Marker({
position: results[0].geometry.location,
map: map,
title:address
});
google.maps.event.addListener(marker,
'click'
,
function
()
{
infowindow.open(map,marker);
});
}
else
{
alert(
"No results found"
);
}
}
else
{
alert(
"Geocode was not successful for the following reason: "
+ status);
}
});
}
}
</script>
</head>
<body onload=
"initialize();"
>
<div id=
"map-canvas"
></div>
</body>
</html>
PHP
Google Map
Google Map with Address