I'm testing WebView on different devices. In the old version (WebView in com.com.com (39.0.0.0)), this function does not work:
var obj = $.parseJSON( data );
console.log(obj);
objectManager.setFilter(function(geoObject) {
return obj.includes(geoObject.id); <---- 1839 Error
});
Logs:
VM203 cmap-ya-android.js:1837 ["25", "59", "63"]
VM203 cmap-ya-android.js:1839 Uncaught TypeError: undefined is not a function
VM203 cmap-ya-android.js:1839 (anonymous function)
......
Everything is OK in the new Chrome: WebView in com.com.com (69.0.3497.100)
This method filters the display of markers on the map according to the documentation:
https://tech.yandex.com.tr/maps/jsapi/doc/2.1/ref/reference/ObjectManager-docpage/#method_detail__setFilter-param-filterFunction and https://yandex.ru/blog/mapsapi/setfilter-peredat-massiv-dannykh
Tell me, how can I adapt Object.include for older devices? (Or create a filter that will work in all versions)
As per https://caniuse.com/#feat=array-includes older browsers do not support Array.prototype.includes. Please rewrite the code using indexOf or use a polyfill for the same.
here you can achieve the same using
var obj = $.parseJSON( data );
console.log(obj);
objectManager.setFilter(function(geoObject) {
return obj.indexOf(geoObject.id) > -1;
});