问题描述
编辑:显示mapManager.filter()
方法的作用。
我有一个Android应用程序,在地图上绘制了约20k个标记,并带有滤镜选项,因此标记被绘制并删除了很多。 我目前正在使用this clustering library,因为它比传统的Google地图库更有效地显示大量标记。但是自3年以来,它不受支持,也没有进行任何更新,而且我还没有找到其他选择。
private void filter(){
//currentMapManager contain all the filters option and also the array list
//of the unfiltered markers (~20,000 markers)
//it's filter method retrieve the current filtering option enable (marker type,and other specs)
//And return markers from the full arraylist that match those filters options.
ArrayList<MarkerModel> filteredList = currentMapManager.filter(currentMapManager.getAllMarkers());
if (clusterManager != null) {
clusterManager.setItems(new ArrayList<>());
clusterManager.onCameraIdle();
clusterManager.setItems(filteredList);
clusterManager.onCameraIdle();
}
这里是mapManager.filter()
方法。
public ArrayList<MarkerModel> filter(List<MarkerModel> currentMarkers) {
ArrayList<Object> filtersArray = filters.getFilters();
/* filtersArray is an array like this :
* ['type',['typeFilter1','typeFilter2'],* 'date',dateTimestamp,* 'withPictures',true,* ....]
*/
return filter(currentMarkers,filtersArray);
}
private ArrayList<MarkerModel> filter(List<MarkerModel> currentMarkers,ArrayList<Object> fieldsAndValues) {
if (fieldsAndValues.size() % 2 == 1) {
throw new IllegalArgumentException("Missing value in call to filterList().
There must be an even number of arguments that alternate between
field names and values");
} else {
//Here the arraylist that we are returning
ArrayList<MarkerModel> filteredMarkers = new ArrayList<>();
List<Object> argumentList = new ArrayList();
Collections.addAll(argumentList,fieldsAndValues);
if (!currentMarkers.isEmpty()) {
for (int j = 0; j < currentMarkers.size(); j++) {
MarkerModel marker = currentMarkers.get(j);
boolean isInFilter = true;
//Check fieldsAndValue filters...
//If isInFilter stay to true we
filteredMarkers.add(marker);
}
}
return filteredMarkers;
}
}
我认为问题在于群集库不应重绘,并且在读取和处理20k项arraylist的过程中在某些时候中断了。 我已经浏览了该库的所有forks分支,并试图了解该库的源代码,但是没有找到解决我问题的方法...
如果您需要我的源代码的其他部分以了解更多信息,请告诉我,我将添加它。
非常感谢您能为我提供帮助,我一直在努力解决这个问题...
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)