Skip to content

Instantly share code, notes, and snippets.

@mureithi254
Last active November 12, 2017 10:16
Show Gist options
  • Save mureithi254/ab5f4521a11f090c9ded362fae159aa4 to your computer and use it in GitHub Desktop.
Save mureithi254/ab5f4521a11f090c9ded362fae159aa4 to your computer and use it in GitHub Desktop.
var EmergData = $.ajax({
url: '/emergencies.json',
dataType: 'text',
success : function(data){
var geojson;
geojson = $.parseJSON(data);
//Adding custom markers to maps
var EmergencyIcon = L.icon({
iconUrl: '<%= asset_path('emergency.png') %>',
iconSize: [30, 60], // size of the icon
iconAnchor: [22, 94], // point of the icon which will correspond to marker's location
shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [-3, -76] // point from which the popup should open relative to the iconAnchor
});
var Custom_marker = L.geoJSON(geojson, {
pointToLayer : function(feature,latlng){
L.marker(latlng,
{icon: EmergencyIcon
}).addTo(mymap).on('mouseover', function() {
this.bindPopup(feature.properties.name + '<br>' + feature.properties.description).openPopup();
});
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment