diff --git a/ground/views/indexTemplate.php b/ground/views/indexTemplate.php
index 0cf2c51..a9fc33c 100644
--- a/ground/views/indexTemplate.php
+++ b/ground/views/indexTemplate.php
@@ -6,7 +6,7 @@
+
Фильтры и поиск
@@ -48,6 +48,10 @@
+
+
+ =$category['name']?>
+
Маршрут
diff --git a/public/js/map.js b/public/js/map.js
index 18907b4..200be9c 100644
--- a/public/js/map.js
+++ b/public/js/map.js
@@ -88,6 +88,8 @@ function init(lat, lng) {
}
});
+ $('.filterSelector').bind('change', function(){filter()});
+
return true;
}
@@ -101,7 +103,7 @@ function constructPoint(data)
id = data['id'];
points[id] = L.marker(
- [data['lat'], data['lng']], {icon: categories[data['categoryId']], title: data['name'],id: id}
+ [data['lat'], data['lng']], {icon: categories[data['categoryId']], title: data['name'], id: id, categoryId: data['categoryId']}
).on('click', function(e){showInfo(e.target.options.id);});
return points[id];
@@ -429,3 +431,23 @@ function closePopup()
if (myMap._popup)
myMap._popup._close();
}
+
+function filter()
+{
+ var selected = new Array();
+ $('.filterSelector:checked').each(function(i, e){
+ selected.push($(e).val());
+ });
+
+ for(var key in points)
+ {
+ if (selected.length == 0 || points[key].options.categoryId == undefined || selected.indexOf(points[key].options.categoryId) != -1)
+ {
+ points[key].addTo(myMap);
+ }
+ else
+ {
+ myMap.removeLayer(points[key]);
+ }
+ }
+}