xxxxxxxxxx
<html>
<head>
<script src='https://api.tiles.mapbox.com/mapbox.js/v0.6.5/mapbox.js'></script>
<script src='states.js'></script>
<script src='https://cdn.jsdelivr.net/gh/dmitrybaranovskiy/raphael/raphael-min.js'></script>
<link
href='https://api.tiles.mapbox.com/mapbox.js/v0.6.5/mapbox.css'
rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.r-vec { position:absolute; }
path {
fill: #000;
fill-opacity: .2;
stroke: #fff;
stroke-width: 1.5px;
}
path:hover {
fill: brown;
fill-opacity: .7;
}
</style>
</head>
<body>
<div id='map'></div>
<script>
function rlayer() {
var f = {}, bounds, paths = [], collection;
f.parent = document.createElement('div');
f.parent.className = 'r-vec';
var R = Raphael(f.parent, 300, 300);
f.project = function(x) {
var point = f.map.locationPoint({ lat: x[1], lon: x[0] });
return [point.x, point.y];
};
var first = true;
f.draw = function() {
R.setSize(f.map.dimensions.x, f.map.dimensions.y);
for (var i = 0; i < collection.features.length; i++) {
var feature = collection.features[i];
var str = '';
var coords = feature.geometry.type === 'Polygon' ? feature.geometry.coordinates[0] : feature.geometry.coordinates[0][0];
str += 'M ' + f.project(coords[1]);
for (var j = 1; j < coords.length; j++) {
str += 'L ' + f.project(coords[j]);
}
str += ' Z ';
if (paths[i]) {
paths[i].attr('path', str);
} else {
paths.push(R.path(str));
}
}
};
f.data = function(x) {
collection = x;
return f;
};
return f;
}
mapbox.auto('map', 'examples.map-vyofok3q', function(map) {
l = rlayer().data(states);
map.addLayer(l);
map.zoom(3);
});
</script>
</body>
</html>
Modified http://api.tiles.mapbox.com/mapbox.js/v0.6.5/mapbox.js to a secure url
Updated missing url https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael-min.js to https://cdn.jsdelivr.net/gh/dmitrybaranovskiy/raphael/raphael-min.js
https://api.tiles.mapbox.com/mapbox.js/v0.6.5/mapbox.js
https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael-min.js