Skip to content

Instantly share code, notes, and snippets.

@tyrel86
Created March 15, 2013 05:33
Show Gist options
  • Save tyrel86/5167688 to your computer and use it in GitHub Desktop.
Save tyrel86/5167688 to your computer and use it in GitHub Desktop.
Leaflet js
$(document).ready( function() {
var user_location = $('user_location')
var user_lat = parseFloat(user_location.data('lat'))
var user_lng = parseFloat(user_location.data('lng'))
var map;
var markers = [];
if($("#map").size() > 0) {
map = L.map('map').setView( [user_lat, user_lng], 11 )
L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png', {
key: 'somekey',
styleId: 12345,
}).addTo(map)
mainIcon = L.icon({
iconUrl: '/assets/marker-icon.png',
// shadowUrl: 'leaf-shadow.png',
iconSize: [29, 38]
// shadowSize: [50, 64]
// iconAnchor: [22, 94]
// shadowAnchor: [4, 62]
// popupAnchor: [-3, -76]
})
featuredIcon = L.icon({
iconUrl: '/assets/featured-marker-icon.png',
// shadowUrl: 'leaf-shadow.png',
iconSize: [42, 56]
// shadowSize: [50, 64]
// iconAnchor: [22, 94]
// shadowAnchor: [4, 62]
// popupAnchor: [-3, -76]
})
$('listing').each( function(index,value) {
value = $(value)
lat = value.data('lat')
lng = value.data('lng')
lat_lng = new L.latLng(lat,lng)
var marker = L.marker(lat_lng,{icon: mainIcon}).addTo(map);
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment