Skip to content

Instantly share code, notes, and snippets.

@mbertrand
Last active February 16, 2021 01:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbertrand/5530456c2816c7cad94b to your computer and use it in GitHub Desktop.
Save mbertrand/5530456c2816c7cad94b to your computer and use it in GitHub Desktop.
China Provinces - TopoJSON version
<!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>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment