0

I'd like to move the ol.extent button that it shows in div.map to new button in another div.

I have the following code but without success:

    <a href="" data-toggle="button" id="buttonSetPosition">Set Position</a>
    <script type="text/javascript">
        $("#buttonSetPosition").on("click", function() {
            $('.ol-zoom-extent').click();
        });
    </script>

Any idea?

1

In 3.7.0 you can do it that way:

var extent = [123,345,567,891];

$('#custom_btn-zoomtoextent').on('click', function () {
        map.getView().fit(extent, map.getSize());
});

(in older Versions it's fitExtent)

0
0

If you want to move the button outside the map div, use the target property of the ol.control.ZoomToExtent class, see api

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.