Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: f763e47dcd
Fetching contributors…

Cannot retrieve contributors at this time

67 lines (63 sloc) 2.116 kB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>USA States</title>
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
<meta name="description" content="A demo that pulls in USA state data from GeoCommons">
<meta name="author" content="Ryan Westphal">
<link rel="stylesheet" href="css/style.css" />
<style type="text/css">
#map { position: fixed; left: 0; top: 0; right: 0; bottom: 0; }
</style>
</head>
<body>
<div>
<div id="map">
</div>
<div class="info">
<div class="links">
<a href="../" class="docLink">&lt; docs</a>
<a href="http://jsfiddle.net/ryanttb/sh8uH/embedded/" class="fiddleLink"><img src="img/jsfiddle.png" alt="" /> jsFiddle &gt;</a>
</div>
<h1>USA States</h1>
<p class="not-mobile">This map reads USA state boundary data as a GeoJSON FeatureCollection and draws it on top of OpenStreetMap.</p>
<p>Click a state to change its color!</p>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
<script src="js/iecors.js"></script>
<script src="http://code.jquerygeo.com/jquery.geo-1.0b1.min.js"></script>
<script>
$(function () {
var map = $("#map").geomap({
center: [-71.0595678, 42.3604823],
zoom: 6,
mode: "drawPoint",
shape: function (e, geo) {
var state = map.geomap("find", geo, 0);
if (state.length > 0) {
map.geomap("remove", state[0]);
var color = Math.round(0xffffff * Math.random()).toString(16);
map.geomap("append", state[0], {
color: "#" + ( color.length == 5 ? "0" : "" ) + color
});
}
}
}),
states = null;
$.ajax({
url: "http://data.jquerygeo.com/usastates.json",
dataType: "json",
success: function (result) {
states = result;
map.geomap("append", states);
},
error: function (xhr) {
alert(xhr.statusText);
}
});
});
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.