cavis/slidemapper — pull request #1 by chrislkeller (2013-04-16 22:30:55+00:00)
Title: Add ability to specify a custom icon in the data.js file

Hello…

I came across this plugin and plan to use it in a project. I wanted to use a custom icon image for map points, and added the code to this branch for you to consider. I'm very much an intermediate beginner, but these seems to follow your current conventions.

Among the commits:

* I added an image file to the example directory.
* I added an icon key with a value to the first object in the data.js file.
* I updated the following in the slidemapper.js file to look for an instance of cfg.icon, and if not, render the usual marker:

// add marker to map
if (cfg.marker) {

// adds class to extend leaflet marker
var LeafIcon = L.Icon.extend({
options: {
shadowUrl: '',
iconSize: [40, 40],
shadowSize: [0, 0],
iconAnchor: [22, 94],
shadowAnchor: [0, 0],
popupAnchor: [-3, -76]
}
});

var latlng = new L.LatLng(cfg.marker[0], cfg.marker[1]);

// creates instance of map icon
if (cfg.icon) {
var mapIcon = new LeafIcon({iconUrl: cfg.icon});
item.marker = L.marker(latlng, {icon: mapIcon});
} else {
item.marker = new L.Marker(latlng);
}

if (cfg.popup) item.marker.bindPopup(cfg.popup);

* I did not update the minified version as I wasn't sure how you created it and didn't want to gum up the works…

Take care and thank you for the work on this.

Chris K.

PS - Do you still work for Public Insight Network?