Created
May 9, 2013 18:10
-
-
Save ramnathv/5549341 to your computer and use it in GitHub Desktop.
Leaflet: Map with Marker
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
require(rCharts) | |
map3 <- Leaflet$new() | |
map3$setView(51.505, -0.09, zoom = 13) | |
map3$tileLayer( | |
"http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png", | |
maxZoom = 18 | |
) | |
map3$marker(51.5, -0.09, bindPopup = "<p> Hi. I am a popup </p>") | |
map3 |
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> | |
<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='chartfb384d3e324a' class='rChart nvd3Plot leaflet'></div> | |
<br/> | |
<pre><code class='r'>require(rCharts) | |
map3 <- Leaflet$new() | |
map3$setView(51.505, -0.09, zoom = 13) | |
map3$tileLayer( | |
"http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png", | |
maxZoom = 18 | |
) | |
map3$marker(51.5, -0.09, bindPopup = "<p> Hi. I am a popup </p>") | |
map3 | |
</code></pre> | |
</div> | |
</div> | |
</div> | |
<script> | |
var spec = { | |
"dom": "chartfb384d3e324a", | |
"width": 800, | |
"height": 400, | |
"center": [ | |
51.505, | |
-0.09 | |
], | |
"viewOpts": [ | |
13 | |
], | |
"urlTemplate": "http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png", | |
"layerOpts": { | |
"maxZoom": 18, | |
"attribution": "Map data © <a href=\"http://openstreetmap.org\">OpenStreetMap</a>contributors, Imagery © <a href=\"http://mapbox.com\">MapBox</a>" | |
}, | |
"id": "chartfb384d3e324a" | |
} | |
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("<p> Hi. I am a popup </p>") | |
/* | |
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