Skip to content

Instantly share code, notes, and snippets.

@jsooriah
Created September 1, 2012 14:36
Show Gist options
  • Save jsooriah/3574971 to your computer and use it in GitHub Desktop.
Save jsooriah/3574971 to your computer and use it in GitHub Desktop.
var map = new L.Map('map', {
center: new L.LatLng(37.7, -122.2),
zoom: 1
});
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/f6d87f028288453dac9ad360255344dd/997/256/{z}/{x}/{y}.png?token=4835534173654176bbb716526fe860b7',
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
map.addLayer(cloudmade);
var blueMarkerIcon = L.Icon.extend({
iconUrl: 'assets/map/marker-lightblue.png',
shadowUrl: 'assets/map/shadow.png',
iconSize: new L.Point(26, 40),
shadowSize: new L.Point(32, 39),
iconAnchor: new L.Point(14, 39),
popupAnchor: new L.Point(0, -35)
});
var yellowMarkerIcon = L.Icon.extend({
iconUrl: 'assets/map/marker-yellow.png',
shadowUrl: 'assets/map/shadow.png',
iconSize: new L.Point(26, 40),
shadowSize: new L.Point(32, 39),
iconAnchor: new L.Point(14, 40),
popupAnchor: new L.Point(13, 12)
});
var blueIcon = new blueMarkerIcon();
var yellowIcon = new yellowMarkerIcon();
console.log("blueIcon : " + blueIcon);
console.log("yellowIcon : " + yellowIcon);
var markersLayer = new L.LayerGroup();
var latLng = new L.LatLng(37.7, -122.2);
var marker = L.marker([37.7, -122.2]);
var popupContent = "<span>content goes here ...</span>";
marker.bindPopup(popupContent, {offset:new L.Point(0,-35)});
markersLayer.addLayer(marker);
map.addLayer(markersLayer);
var popup = L.popup();
function onMapClick(e) {
/* Save in local storageHere */
// Tests if departure locations already exists,
// if yes, save as departure latitude and longitude
// if no, save as arrival latitude and longitude
window.localStorage.setItem("pickUpLatitude", user);
window.localStorage.setItem("pickUpLongitude", pass);
popup.setLatLng(e.latlng).setContent("You clicked the map at " + e.latlng.toString()).openOn(map);
}
map.on('click', onMapClick);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment