Getting the eventargs of registered events

Posted by Bjorn Vdkerckhove on Stack Overflow See other posts from Stack Overflow or by Bjorn Vdkerckhove
Published on 2014-06-10T09:14:15Z Indexed on 2014/06/10 9:24 UTC
Read the original article Hit count: 175

Filed under:

i'm new with maps and openlayers, but i'm playing around with openlayers because i'll need mapfunctionality in my next project. The map is an image (because it's a drawn map of a medieval town).

I found how i can register events, and it's working. But the problem is, that the "eventargs" is not working as in the examples i found. In one of the examples they are getting the x and y values after the users panned like this:

map.events.register('moveend', map, function (e)
{
    alert(e.xy);
});

If i try this in visual studio, e doesn't have a 'xy' property. What am i missing? This is the code i have right now:

<script type="text/javascript">



        var map, layer;

        function init() {
            var windowHeight = $(window).height();
            var windowWidth = $(window).width();
            var mapdiv = $('#map');
            mapdiv.css({width: windowWidth + 'px', height: windowHeight + 'px'});

            map = new OpenLayers.Map('map', { maxResolution: 1000 });
            layer = new OpenLayers.Layer.Image(
             'Globe ESA',
             '[url]',
             new OpenLayers.Bounds(-180.0, -12333.5, 21755.5, 90.0),
             new OpenLayers.Size(windowWidth, windowHeight),
             { numZoomLevels: 100 });
            map.addLayer(layer);
            nav = new OpenLayers.Control.Navigation();
            map.addControl(nav);
            //events test
            map.events.register('moveend', map, function (e)
            {
                alert(e.xy);
            });
            map.zoomToMaxExtent();
        }
    </script>

In the examples of openlayer, they don't use the eventargs, but there must be a way to get the zoomlevel, or the x and y after panning, right?

Thank you!

© Stack Overflow or respective owner

Related posts about openlayers