Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Google Map with Address by using PHP
WhatsApp
Vinod Verma
Oct 10
2014
2.6
k
0
1
<!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
Up Next
Google Map with Address by using PHP