Last active
August 29, 2015 14:13
-
-
Save lsongdev/090a00cc8b01ec3284d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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