diff --git a/assets/CustomMarkers.js b/assets/CustomMarkers.js
new file mode 100644
index 0000000..ffd58c0
--- /dev/null
+++ b/assets/CustomMarkers.js
@@ -0,0 +1,47 @@
+var CustomMarkers = {
+ marker_array: { //private list of icons, not meant for direct access
+ default: new L.divIcon({
+ html: '',
+ iconSize:[14, 34],
+ iconAnchor: [7, 26],
+ className: 'leaflet-default-custom-marker',
+ }),
+ color: {},
+ },
+ getMarker: function(name, color) {
+ if (name == 'default' || !name) {
+ if (!color) {
+ return this.marker_array.default;
+ } else {
+ return this.getReplaceDefaultColor(color, '#4dea51');
+ }
+ } else {
+ return this.getCustomMarker(name);
+ }
+ },
+ getReplaceDefaultColor: function(newcolor, defaultcolor) {
+ if (!this.marker_array.color[newcolor]) { //only do this once for each color each load
+ var ret = this.marker_array.default.options.html.replace(defaultcolor, newcolor);
+ this.marker_array.color[newcolor] = new L.divIcon({
+ html: ret,
+ iconSize: this.marker_array.default.options.iconSize,
+ iconAnchor: this.marker_array.default.options.iconAnchor,
+ className: this.marker_array.default.options.className,
+ });
+ }
+ return this.marker_array.color[newcolor];
+ },
+
+ getCustomMarker: function(name) {
+ if (!this.marker_array[name]) {
+ this.marker_array[name] = new L.Icon({
+ iconUrl: 'assets/images/icons/' + name + '.svg',
+ iconAnchor: [10, 40], //assuming our icons are set internally as 20x40
+ className: 'leaflet-' + name + '-custom-marker',
+ });
+ }
+
+ return this.marker_array[name];
+ }
+
+};
diff --git a/assets/main.js b/assets/main.js
index 8941494..bce52ad 100644
--- a/assets/main.js
+++ b/assets/main.js
@@ -1182,11 +1182,9 @@ function create_topojson_layer(dataset) {
if (dataset.type === "regions" || dataset.type === "points") {
newLayer.setStyle(dataset.style);
newLayer.options.pointToLayer = function(feature, latlng) {
- var smallIcon = L.VectorMarkers.icon({
- icon: 'circle',
- markerColor: dataset.style.color
- });
- return L.marker(latlng, {icon: smallIcon});
+ var icon_name = dataset.icon ? dataset.icon : 'default';
+ smallIcon = CustomMarkers.getMarker(icon_name, dataset.style.color);
+ return L.marker(latlng,{icon: smallIcon});
};
}
newLayer.on("mouseover", function(e) {
diff --git a/buildtools/optimize-js.sh b/buildtools/optimize-js.sh
index 645910f..a10464f 100755
--- a/buildtools/optimize-js.sh
+++ b/buildtools/optimize-js.sh
@@ -18,7 +18,7 @@ touch ./start.js
echo "load_map_data(\"topojson\");" >> ./start.js
-uglifyjs --prefix relative --output ${outpath}main.${now}.min.js --screw-ie8 --mangle --compress dead_code,loops,warnings,join_vars --reserved '$,L,map,window,data_obj' --stats --verbose -- ../assets/jquery-1.11.2/jquery.min.js ../assets/spin-2.1.0/spin.min.js ../assets/leaflet-0.7.3/js/leaflet.js ../assets/leaflet-0.7.3/js/Leaflet.vector-markers.js ../assets/leaflet-0.7.3/js/leaflet-providers.js ../assets/leaflet-0.7.3/js/leaflet-pip.min.js ../assets/leaflet-0.7.3/js/leaflet.spin.js ../assets/leaflet-0.7.3/js/leaflet.geojsoncss.min.js ../assets/leaflet-0.7.3/js/l.control.geosearch.js ../assets/leaflet-0.7.3/js/l.geosearch.provider.openstreetmap.js ../assets/leaflet-0.7.3/js/L.Control.Pan.js ../assets/leaflet-0.7.3/js/L.Control.ZoomBox.min.js ../assets/leaflet-0.7.3/js/leaflet.defaultextent.js ../assets/leaflet-0.7.3/js/leaflet.groupedlayercontrol.min.js ../assets/topojson-1.0/topojson.v1.min.js ../assets/leaflet-0.7.3/js/L.TopoJSON.min.js ../assets/main.js ./start.js
+uglifyjs --prefix relative --output ${outpath}main.${now}.min.js --screw-ie8 --mangle --compress dead_code,loops,warnings,join_vars --reserved '$,L,map,window,data_obj' --stats --verbose -- ../assets/jquery-1.11.2/jquery.min.js ../assets/spin-2.1.0/spin.min.js ../assets/leaflet-0.7.3/js/leaflet.js ../assets/leaflet-0.7.3/js/Leaflet.vector-markers.js ../assets/leaflet-0.7.3/js/leaflet-providers.js ../assets/leaflet-0.7.3/js/leaflet-pip.min.js ../assets/leaflet-0.7.3/js/leaflet.spin.js ../assets/leaflet-0.7.3/js/leaflet.geojsoncss.min.js ../assets/leaflet-0.7.3/js/l.control.geosearch.js ../assets/leaflet-0.7.3/js/l.geosearch.provider.openstreetmap.js ../assets/leaflet-0.7.3/js/L.Control.Pan.js ../assets/leaflet-0.7.3/js/L.Control.ZoomBox.min.js ../assets/leaflet-0.7.3/js/leaflet.defaultextent.js ../assets/leaflet-0.7.3/js/leaflet.groupedlayercontrol.min.js ../assets/topojson-1.0/topojson.v1.min.js ../assets/leaflet-0.7.3/js/L.TopoJSON.min.js ../assets/main.js ../assets/CustomMarkers.js ./start.js
# --source-map ${outpath}main.${now}.min.js.map --source-map-root http://localhost:8000/assets --source-map-url
# IE 8
@@ -31,7 +31,7 @@ touch ./start-ie8.js
echo "load_map_data(\"geojson\");" >> ./start-ie8.js
-uglifyjs --prefix relative --output ${outpath}main.ie8.${now}.min.js --mangle --compress dead_code,loops,warnings,join_vars --reserved '$,L,map,window,data_obj' --stats --verbose -- ../assets/ie8_polyfills.js ../assets/jquery-1.11.2/jquery.min.js ../assets/spin-2.1.0/spin.min.js ../assets/leaflet-0.7.3/js/leaflet.js ../assets/leaflet-0.7.3/js/Leaflet.vector-markers.js ../assets/leaflet-0.7.3/js/leaflet-providers.js ../assets/leaflet-0.7.3/js/leaflet-pip.min.js ../assets/leaflet-0.7.3/js/leaflet.spin.js ../assets/leaflet-0.7.3/js/leaflet.geojsoncss.min.js ../assets/leaflet-0.7.3/js/l.control.geosearch.js ../assets/leaflet-0.7.3/js/l.geosearch.provider.openstreetmap.js ../assets/leaflet-0.7.3/js/L.Control.Pan.js ../assets/leaflet-0.7.3/js/L.Control.ZoomBox.min.js ../assets/leaflet-0.7.3/js/leaflet.defaultextent.js ../assets/leaflet-0.7.3/js/leaflet.groupedlayercontrol.min.js ../assets/main.js ./start-ie8.js
+uglifyjs --prefix relative --output ${outpath}main.ie8.${now}.min.js --mangle --compress dead_code,loops,warnings,join_vars --reserved '$,L,map,window,data_obj' --stats --verbose -- ../assets/ie8_polyfills.js ../assets/jquery-1.11.2/jquery.min.js ../assets/spin-2.1.0/spin.min.js ../assets/leaflet-0.7.3/js/leaflet.js ../assets/leaflet-0.7.3/js/Leaflet.vector-markers.js ../assets/leaflet-0.7.3/js/leaflet-providers.js ../assets/leaflet-0.7.3/js/leaflet-pip.min.js ../assets/leaflet-0.7.3/js/leaflet.spin.js ../assets/leaflet-0.7.3/js/leaflet.geojsoncss.min.js ../assets/leaflet-0.7.3/js/l.control.geosearch.js ../assets/leaflet-0.7.3/js/l.geosearch.provider.openstreetmap.js ../assets/leaflet-0.7.3/js/L.Control.Pan.js ../assets/leaflet-0.7.3/js/L.Control.ZoomBox.min.js ../assets/leaflet-0.7.3/js/leaflet.defaultextent.js ../assets/leaflet-0.7.3/js/leaflet.groupedlayercontrol.min.js ../assets/main.js ../assets/CustomMarkers.js ./start-ie8.js
# --source-map ${outpath}main.ie8.${now}.min.js.map --source-map-root http://localhost:8000/assets --source-map-url
# Datasets Credits
diff --git a/index.html b/index.html
index 3c11f67..1fb21c6 100644
--- a/index.html
+++ b/index.html
@@ -65,6 +65,7 @@
-->
+