I have a map that contains a lot of features that are added dynamically.
I want to detech the last added point if it is on the screen, or not. And when it is, i want to play a short notofication sound.
Like this:
if (ol.extent.containsCoordinate(map.getExtent(), ol.proj.transform([parseFloat(data.lon), parseFloat(data.lat)], 'EPSG:4326', 'EPSG:3857')))
{
var audio = new Audio('tick.wav');
audio.play();
}
But I cannot find any method to get the current bounding of the screen in the docs of OpenLayers 3.
I found the solution, this is missing from the docs.
if (ol.extent.containsCoordinate(map.getView().calculateExtent(map.getSize()), ol.proj.transform([parseFloat(data.lon), parseFloat(data.lat)], 'EPSG:4326', 'EPSG:3857')))
{
var audio = new Audio('tick.wav');
audio.play();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.