Open Layers: Is Fanning Supported?

Hi,

If i have more than 10 000 objects in minimum zoom , the user will see all the objects as one single point.
But the map draws the 10 000 objects which makes the rendering very slow!
if fanning exists, the map should draw multiple objects as one object at a certain zoom level, and once the zooming is extended the multiple objects are drawn.

Thanks,
Dany

Hi,

Modifying visible vectors during panning?

The API currently lacks a listener for extent change. There is a ticket for it, but I haven’t found time to work with this add-on lately although I’d love to. Luckily there is a easy workaround: you can override updateExtent method like this (code snippet from TouchKit demo app called Vornitologist):


            openLayersMap = new OpenLayersMap() {
                @Override
                protected void updateExtent(
                        java.util.Map<String, Object> variables) {
                    super.updateExtent(variables);
                    updateMarkers();
                };
            };
           openLayersMap.setImmediate(true);

In updateMarkers you can read the current extent and then query your backend for relevant items. This is how it is done in the Vornitologist:


    public void updateMarkers() {
        Bounds extent = openLayersMap.getExtend();

        ObservationPoint topLeft = new ObservationPoint();
        topLeft.setLatitude(extent.getMaxLat());
        topLeft.setLongitude(extent.getMinLon());
        ObservationPoint bottomRight = new ObservationPoint();
        bottomRight.setLatitude(extent.getMinLat());
        bottomRight.setLongitude(extent.getMaxLon());

        List<Observation> observations = ObservationDB.getObservations(null,
                topLeft, bottomRight, 15, 1);
        markerLayer.removeAllComponents();
        for (Observation observation : observations) {
            ObservationPoint location = observation.getLocation();
            PointVector marker = new PointVector(location.getLongitude(),
                    location.getLatitude());
            marker.setData(observation);
            markerLayer.addVector(marker);
        }
        if (markerLayer.getParent() == null) {
            openLayersMap.addLayer(markerLayer);
        }

    }

cheers,
matti

Hi Matti,

Thanks for your quick reply. i’ll try it and get back to you.

Cheers,
Dany