Skip to content

Instantly share code, notes, and snippets.

@JKetelaar
Created December 5, 2013 12:48
Show Gist options
  • Save JKetelaar/7804633 to your computer and use it in GitHub Desktop.
Save JKetelaar/7804633 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<textarea id="txtAddress" rows="3" cols="25"></textarea>
<br />
<input type="button" onclick="initialize()" value="Get Location" />
<div id="googleMap" style="width:500px;height:380px;"></div>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
function initialize() {
var geocoder = new google.maps.Geocoder();
var address = document.getElementById("txtAddress").value;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
var myCenter = new google.maps.LatLng(latitude, longitude);
var mapProp = {center: myCenter, zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
var marker = new google.maps.Marker({position: myCenter, animation: google.maps.Animation.BOUNCE});
marker.setMap(map);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment