Created
September 4, 2014 12:26
-
-
Save javisantana/befa66fc9327f6c2908e to your computer and use it in GitHub Desktop.
add a search box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Gmaps example | 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://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" /> | |
</head> | |
<body> | |
<div id="map"></div> | |
<!-- include google maps library *before* load cartodb.js --> | |
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> | |
<!-- include cartodb.js library --> | |
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.uncompressed.js"></script> | |
<script> | |
function main() { | |
var map; | |
// create google maps map | |
var mapOptions = { | |
zoom: 3, | |
center: new google.maps.LatLng(43, 0), | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
map = new google.maps.Map(document.getElementById('map'), mapOptions); | |
// create layer and add to the map, then add some intera | |
cartodb.createLayer(map, 'http://documentation.cartodb.com/api/v2/viz/2b13c956-e7c1-11e2-806b-5404a6a683d5/viz.json') | |
.addTo(map) | |
.on('done', function(layer) { | |
var v = cdb.vis.Overlay.create('search', map.viz, {}) | |
v.show(); | |
$('#map').append(v.render().el); | |
}) | |
.on('error', function() { | |
cartodb.log.log("some error occurred"); | |
}); | |
} | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment