我正在尝试使用OpenStreetMap将美国地图拖入网页并为某些州(例如:NY,WI,KS)着色。
我的代码仅提取了地图的一部分,而不是整个国家。有人可以帮忙吗?
<html>
<head>
<title>Map Page</title>
<style type="text/css">
html, body, #basicMap {
width: 90%;
height: 90%;
margin: 10;
text-align:center;
}
</style>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
function init() {
map = new OpenLayers.Map("basicMap");
var mapnik = new OpenLayers.Layer.OSM();
var fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
var position = new OpenLayers.LonLat(-119.310191, 36.853292).transform( fromProjection, toProjection);
var zoom = 15;
map.addLayer(mapnik);
map.setCenter(position, zoom );
}
</script>
</head>
<body body bgcolor="#ecf9e3" onload="init();">
<div id="basicMap"></div>
</body>
</html>