Map example

Example of creating a map using leafletjs for Intro to JavaScript

HTML

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.6/leaflet.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.6/leaflet.js"></script>
<div style="width:100%;height:400px" id="map"></div>

JavaScript

// Create a map, set the view and zoom level
var map = L.map('map').setView([-27.48,153.02],14);

// use tiles from Mapquest
var mapquestUrl = 'http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png',
 subDomains = ['otile1','otile2','otile3','otile4']; 

L.tileLayer(mapquestUrl, 
            {maxZoom: 18, subdomains: subDomains}
           ).addTo(map);

// attach a marker with a popup
L.marker([-27.48,153.02]).addTo(map)
    .bindPopup('South Bank, Brisbane')
    .openPopup();