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
Search Address in Google Map using JavaScript Code in HTML
Mohd Arif
Dec 01
2015
Code
3.1
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<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