cdb
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet vector hover | CartoDB.js</title>
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
|
||||
|
||||
<style>
|
||||
html, body, #map {
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
|
||||
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
|
||||
<script src="https://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.core.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
function main() {
|
||||
|
||||
var map = L.map('map', {
|
||||
zoomControl: false,
|
||||
center: [43, 0],
|
||||
zoom: 3
|
||||
})
|
||||
|
||||
var sql = new cartodb.SQL({ user: 'examples', format: 'geojson' });
|
||||
|
||||
L.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', {
|
||||
attribution: 'Stamen'
|
||||
}).addTo(map);
|
||||
|
||||
// create the layer and add to the map, then will be filled with data
|
||||
var countriesLayer = L.geoJson(null, {
|
||||
style: {
|
||||
color: "#ff0000",
|
||||
fillColor: "#ff0000",
|
||||
weight: 1,
|
||||
opacity: 0.65
|
||||
}
|
||||
}).addTo(map);
|
||||
|
||||
sql.execute("select cartodb_id, area, ST_Simplify(the_geom, 0.1) as the_geom from european_countries_e").done(function(geojson) {
|
||||
countriesLayer.addData(geojson);
|
||||
countriesLayer.on('mouseover', function(e) {
|
||||
e.layer.setStyle({
|
||||
weight: 3,
|
||||
opacity: 1
|
||||
});
|
||||
})
|
||||
countriesLayer.on('mouseout', function(e) {
|
||||
countriesLayer.resetStyle(e.layer);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
window.onload = main;
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user