Created
May 9, 2013 17:47
-
-
Save ramnathv/5549179 to your computer and use it in GitHub Desktop.
Leaflet: Second Map
This file contains hidden or 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
| require(rCharts) | |
| map2 = Leaflet$new() | |
| map2$setView(45.5236, -122.675, 10) | |
| map2$tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png") | |
| map2 |
This file contains hidden or 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> | |
| <link rel='stylesheet' href="http://netdna.bootstrapcdn.com/bootswatch/2.3.1/cosmo/bootstrap.min.css"> | |
| <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" > | |
| <link rel='stylesheet' href="http://twitter.github.io/bootstrap/assets/js/google-code-prettify/prettify.css"> | |
| <link rel='stylesheet' href='http://leafletjs.com/dist/leaflet.css'> | |
| <script src='http://leafletjs.com/dist/leaflet.js' type='text/javascript'></script> | |
| <style> | |
| .rChart { | |
| display: block | |
| margin: auto auto; | |
| width: 800px; | |
| height: 400px; | |
| } | |
| body { | |
| margin-top: 60px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class='container'> | |
| <div class='row'> | |
| <div class='span9'> | |
| <div id='chartfa9e9b76528' class='rChart nvd3Plot leaflet'></div> | |
| <br/> | |
| <pre><code class='r'>require(rCharts) | |
| map2 = Leaflet$new() | |
| map2$setView(45.5236, -122.675, 10) | |
| map2$tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png") | |
| map2 | |
| </code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| var spec = { | |
| "dom": "chartfa9e9b76528", | |
| "width": 800, | |
| "height": 400, | |
| "center": [ | |
| 45.524, | |
| -122.67 | |
| ], | |
| "viewOpts": [ | |
| 10 | |
| ], | |
| "urlTemplate": "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", | |
| "layerOpts": { | |
| "attribution": "Map data © <a href=\"http://openstreetmap.org\">OpenStreetMap</a>contributors, Imagery © <a href=\"http://mapbox.com\">MapBox</a>" | |
| }, | |
| "id": "chartfa9e9b76528" | |
| } | |
| var map = L.map(spec.dom) | |
| .setView(spec.center, spec.viewOpts); | |
| L.tileLayer(spec.urlTemplate, spec.layerOpts) | |
| .addTo(map); | |
| /* | |
| L.marker([51.5, -0.09]).addTo(map) | |
| .bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup(); | |
| L.marker([51.52, -0.09]).addTo(map) | |
| .bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup(); | |
| L.circle([51.508, -0.11], 500, { | |
| color: 'red', | |
| fillColor: '#f03', | |
| fillOpacity: 0.5 | |
| }).addTo(map).bindPopup("I am a circle."); | |
| L.polygon([ | |
| [51.509, -0.08], | |
| [51.503, -0.06], | |
| [51.51, -0.047] | |
| ]).addTo(map).bindPopup("I am a polygon."); | |
| var popup = L.popup(); | |
| function onMapClick(e) { | |
| popup | |
| .setLatLng(e.latlng) | |
| .setContent("You clicked the map at " + e.latlng.toString()) | |
| .openOn(map); | |
| } | |
| map.on('click', onMapClick); | |
| */ | |
| </script> | |
| </body> | |
| <!-- Google Prettify --> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/188.0.0/prettify.js"></script> | |
| <script | |
| src='https://google-code-prettify.googlecode.com/svn-history/r232/trunk/src/lang-r.js'> | |
| </script> | |
| <script> | |
| var pres = document.getElementsByTagName("pre"); | |
| for (var i=0; i < pres.length; ++i) { | |
| pres[i].className = "prettyprint linenums"; | |
| } | |
| prettyPrint(); | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment