Реализовал фильтрацию
This commit is contained in:
parent
06704acaeb
commit
32c43b03c0
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="glyphicon glyphicon-minus big _b" title="Отдалить" onclick="myMap.zoomOut()"></div>
|
<div class="glyphicon glyphicon-minus big _b" title="Отдалить" onclick="myMap.zoomOut()"></div>
|
||||||
|
|
||||||
<div class="glyphicon glyphicon-globe _t boxButtonLayers" onclick="openBox('Layers')" title="Слои карты"></div>
|
<div class="glyphicon glyphicon-globe _t boxButtonLayers" onclick="openBox('Layers')" title="Слои карты"></div>
|
||||||
<div class="glyphicon glyphicon-filter _c boxButtonFilter" title="Фильтры" onclick="openBox('Filter')"></div>
|
<div class="glyphicon glyphicon-filter _c boxButtonFilter" title="Фильтры и поиск" onclick="openBox('Filter')"></div>
|
||||||
<div class="glyphicon glyphicon-flag _b" title="Я на карте" onclick="showMeOnTheMap()"></div>
|
<div class="glyphicon glyphicon-flag _b" title="Я на карте" onclick="showMeOnTheMap()"></div>
|
||||||
<div class="glyphicon glyphicon-list boxButtonRoute" title="Маршрут" onclick="openBox('Route')"></div>
|
<div class="glyphicon glyphicon-list boxButtonRoute" title="Маршрут" onclick="openBox('Route')"></div>
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
<div onclick="setLayer('yandex')" class="layers yandexLayer">Яндекс.Карты</div>
|
<div onclick="setLayer('yandex')" class="layers yandexLayer">Яндекс.Карты</div>
|
||||||
<div onclick="setLayer('yandexMap')" class="layers yandexMapLayer">Яндекс.Карты (схема)</div>
|
<div onclick="setLayer('yandexMap')" class="layers yandexMapLayer">Яндекс.Карты (схема)</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="boxFilter">
|
<div id="boxFilter" style="height: 100%; overflow-y: auto;">
|
||||||
<h3>Фильтры и поиск</h3>
|
<h3>Фильтры и поиск</h3>
|
||||||
<span class="input-group">
|
<span class="input-group">
|
||||||
<input type="text" id="addressField" class="form-control" placeholder="Поиск на карте..." onkeydown="if(event.keyCode == 13) {searchAdderess()}" />
|
<input type="text" id="addressField" class="form-control" placeholder="Поиск на карте..." onkeydown="if(event.keyCode == 13) {searchAdderess()}" />
|
||||||
|
|
@ -48,6 +48,10 @@
|
||||||
<button class="btn btn-default" type="button" onclick="searchAdderess()"><span class="glyphicon glyphicon-search"></span></button>
|
<button class="btn btn-default" type="button" onclick="searchAdderess()"><span class="glyphicon glyphicon-search"></span></button>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
<br />
|
||||||
|
<?php foreach ($categories as $category): ?>
|
||||||
|
<input type="checkbox" value="<?=$category['id']?>" class="filterSelector"> <?=$category['name']?><br/>
|
||||||
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
<div id="boxRoute" style="height: 100%; overflow-y: auto;">
|
<div id="boxRoute" style="height: 100%; overflow-y: auto;">
|
||||||
<h3>Маршрут</h3>
|
<h3>Маршрут</h3>
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,8 @@ function init(lat, lng) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.filterSelector').bind('change', function(){filter()});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +103,7 @@ function constructPoint(data)
|
||||||
id = data['id'];
|
id = data['id'];
|
||||||
|
|
||||||
points[id] = L.marker(
|
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);});
|
).on('click', function(e){showInfo(e.target.options.id);});
|
||||||
|
|
||||||
return points[id];
|
return points[id];
|
||||||
|
|
@ -429,3 +431,23 @@ function closePopup()
|
||||||
if (myMap._popup)
|
if (myMap._popup)
|
||||||
myMap._popup._close();
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue