Last active
February 16, 2021 01:50
-
-
Save mbertrand/5530456c2816c7cad94b to your computer and use it in GitHub Desktop.
China Provinces - TopoJSON version
This file contains 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>HTML5</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=650, user-scalable=yes"> | |
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> | |
</script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.js"></script> | |
<style> | |
html, body { | |
height: 100%; | |
margin: 0; | |
} | |
#mapcanvas{ | |
height:100%; | |
} | |
</style> | |
<script> | |
var geoJsonObject; | |
var thejson; | |
$(document).ready(function(){ | |
var mapOptions = { | |
zoom: 4, | |
center: new google.maps.LatLng(38.284335, 110.833818), | |
mapTypeId: google.maps.MapTypeId.TERRAIN | |
}; | |
map=new google.maps.Map($('#mapcanvas')[0], mapOptions); | |
//topochina.json is a topojson file | |
$.getJSON("topochina.json", function(data){ | |
geoJsonObject = topojson.feature(data, data.objects["regions.geo"]) | |
map.data.addGeoJson(geoJsonObject); | |
}); | |
});//end document ready | |
</script> | |
</head> | |
<body> | |
<div id="mapcanvas"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment