Skip to content

Instantly share code, notes, and snippets.

@lsongdev
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save lsongdev/090a00cc8b01ec3284d7 to your computer and use it in GitHub Desktop.

Select an option

Save lsongdev/090a00cc8b01ec3284d7 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Maps</title>
<script src="http://maps.googleapis.com/maps/api/js"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function(){
var googleMap = document.getElementById("googleMap")
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readyState = 4 && xhr.status == 200){
var data = JSON.parse(xhr.responseText);
var ll = new google.maps.LatLng(data.geo.ll[0], data.geo.ll[1]);
var map = new google.maps.Map(googleMap, {
zoom: 15,
center: ll,
mapTypeId:google.maps.MapTypeId.ROADMAP
});
};
};
xhr.open('GET', 'https://api.lsong.org/ip/all', false);
xhr.send();
});
</script>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment