Skip to content

Instantly share code, notes, and snippets.

@marti1125
Created January 27, 2014 16:47
Show Gist options
  • Save marti1125/8652263 to your computer and use it in GitHub Desktop.
Save marti1125/8652263 to your computer and use it in GitHub Desktop.
agregar iconos al mapa en mapbox
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