Created
January 27, 2014 16:47
-
-
Save marti1125/8652263 to your computer and use it in GitHub Desktop.
agregar iconos al mapa en mapbox
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
function mostrarMapa(){ | |
var geoJson = []; | |
var map = L.mapbox.map('mapbox', 'osgux.g99506jm'); | |
$.getJSON('js/estaciones.json', function(response){ | |
$.each(response, function(index, item){ | |
geoJson.push({ | |
"type": "Feature", | |
"geometry": { | |
"type": "Point", | |
"coordinates": [item.longitud,item.latitud] | |
}, | |
"properties": { | |
"title": "Estación " + item.estacion, | |
"icon": { | |
"iconUrl": "./js/train.png", | |
"iconSize": [32, 37] | |
} | |
} | |
}); | |
map.markerLayer.on('layeradd', function(e) { | |
var marker = e.layer, | |
feature = marker.feature; | |
marker.setIcon(L.icon(feature.properties.icon)); | |
}); | |
map.markerLayer.setGeoJSON(geoJson); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment