vuelayers icon indicating copy to clipboard operation
vuelayers copied to clipboard

Standard OpenLayers controls

Open ghettovoice opened this issue 6 years ago • 12 comments

Currently VueLayers doesn't has any components for OpenLayers standard controls. And the only way to work with them is through underlying ol.Map instance of the vl-map component. The main goal is to implement an all standard controls to easily work with them as Vue components:

Also an basic control mixin as a base type for all controls should be implemented to allow easy extending.

Usage example:

// by default nothing is enabled
<vl-map ...></vl-map>

// map with default set  of controls
<vl-map ...>
  <vl-control-default-set ...></vl-control-default-set>
</vl-map>

// map with custom controls markup
<vl-map ...>
  <vl-control-zoom ...></vl-control-zoom>
  <vl-control-scale-line ...></vl-control-scale-line>
  ...
</vl-map>

ghettovoice avatar Oct 29 '18 18:10 ghettovoice

I have just noticed with v0.11.0-rc.5 that the attribution control is not collapsed and not collapsible. I think that in previous versions it was both collapsed and collapsible. This may be because of something I have done.

It is not much of an issue for me as I know how to change it, so no action needed from you. In any case I see that in this issue you are intending to make it easier to specify, so I can wait for v0.12,

PeterC66 avatar Nov 13 '18 09:11 PeterC66

Thanks @PeterC66 ! I'll take this into account

ghettovoice avatar Nov 13 '18 10:11 ghettovoice

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 05 '19 17:05 stale[bot]

Before you work on the implementaiton of this one. Can you please allow to provide a Controls Collection to the vl-map controls property ? (same for an Interactions Collection) src/component/map/map.vue#L349-L351

To at least be able to use the following as controls :

import {defaults as defaultControls, ScaleLine} from 'ol/control.js';

...
  data() {
    return {
      controls: defaultControls().extend([
        scaleLineControl
      ]),
    }
  }

Swizz avatar Sep 26 '19 09:09 Swizz

Ok, I'll make this, for a while this is a suitable solution

ghettovoice avatar Sep 27 '19 06:09 ghettovoice

Possible release ? 😃

Swizz avatar Oct 02 '19 09:10 Swizz

Release as v0.11.5, please upgrade

ghettovoice avatar Oct 03 '19 16:10 ghettovoice

Works like a charm, big thanks

Swizz avatar Oct 04 '19 09:10 Swizz

@ghettovoice I have version 0.12.6 and adding adding <vl-control-scale-line></vl-control-scale-line> just results in an unknown component. Has this changed since 0.11.5?

iboates avatar Dec 06 '22 15:12 iboates

Hello @iboates ,

No, vuelayers still hasn't separate control components like vl-control-.... . But you still can append any OpenLayers controls in created event handler.

<vl-map @created="mapCreated">...</vl-map>

mapCreated (mapVm) {
  mapVm.addControls(
    new ScaleLine(...),
    new ....,
  )
}

ghettovoice avatar Dec 07 '22 11:12 ghettovoice

Thank you. How do you import it? I have imported it as

import { ScaleLine } from 'ol/control';

But then I get

AssertionError: value is an instance of Control

...

// in methods
mapCreated (mapVm) {
      mapVm.addControls(
        new ScaleLine({
          units: "metric",
          minWidth: 140,
        })
      )

iboates avatar Dec 07 '22 14:12 iboates

sorry, I found an error in my example. You should pass array to addControls method:

mapVm.addControls([
    new ScaleLine(...),
    new ....,
  ])

To add single control you can use: mapVm.addControl(new ScaleLine())

UPD: your import of control is correct

ghettovoice avatar Dec 08 '22 08:12 ghettovoice