[proposition] new general layer for geojson markers
I wanted to use another marker other than vector and awesome, but I don't want to use custom layer. so I created this general layer geojsonMarker as layerType:
geoJSONMarker: {
mustHaveUrl: false,
createLayer: function (params) {
if(!params.markerClass || !(params.markerClass in L)){
return $log.error('no marker class found');
}
var config = {
pointToLayer: function (feature, latlng) {
var marker = L.marker(latlng, {icon: L[params.markerClass].icon(params.icon)});
if (params.options.pointToLayer) {
marker = params.options.pointToLayer(feature, latlng, marker);
}
return marker;
}
};
['style','filter','coordsToLatLng','onEachFeature'].forEach(function(key){
if (params.options[key]) {
config[key] = params.options[key];
}
});
return new L.geoJson(params.data, config);
}
},
you can passe this config:
{
type: 'geoJSONMarker',
name: 'marker name',
data:geojsonData,
markerClass:'MakiMarkers', //could be VectorMarkers, or AwesomeMarkers
visible: true,
icon: {
icon: "grocery",
color: '#000',
size: "m"
},
layerOptions: {
pointToLayer: pointToLayer,
onEachFeature: bindPopup
}
}
all available layerOptions can be found in official doc
pointToLayer has third parameter marker, in case user wants to modify marker or icon
I don't know if it's a good idea, so I just posted here to discuss instead of firing a PR.
@gitawego I would suggest making a plugin so it can be pulled into this project. We are trying to break the project up to unixify it. IE see
- https://github.com/elesdoar/ui-leaflet-layers
- https://github.com/angular-ui/ui-leaflet-draw
yeah that's a better idea. my solution is just for the short-term needs.
Ok if it is for short term needs then PR it to 1.X with a spec and example to make sure it works. But please plan to follow up with a repo of your own to support the layer or PR it to ui-leaflet-layers.