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
Search Address in Google Map using JavaScript Code in HTML
WhatsApp
Mohd Arif
Dec 01
2015
3.4
k
0
0
<html>
<head>
<meta name=
"viewport"
content=
"initial-scale=1.0, user-scalable=no"
/>
<meta http-equiv=
"content-type"
content=
"text/html; charset=UTF-8"
/>
<title>Geo Code </title>
<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 =
"New Delhi"
;
function initialize()
{
geocoder =
new
google.maps.Geocoder();
var latlng =
new
google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 14,
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 style=
"margin:0px; padding:0px;"
onload=
"initialize()"
>
<div id=
"map_canvas"
style=
"width:100%; height:100%"
>
</body>
</html>
Address search, search address using JavaScript ,search address on Google map, search dynamic address in Google map, search Geocode.
HTML
Google Map
JavaScript
Up Next
Search Address in Google Map using JavaScript Code in HTML