Linking Angular 4 and OpenLayers 4

Viewed 3482

I have two components:

  • map
  • controls

I want the buttons on the controls component to interact with the map. Example adding an interaction to the map:

Controls component:

  • HTML: <button (click)="add_a_place()" type="button">Add a place</button>
  • JS: add_a_place() {map.addInteraction(draw_interaction)}

Map component:

  • JS:

var draw_interaction = new ol.interaction.Draw({ source: vector_source, type: "Point" }); var map = new ol.Map({ target: "map", layers: [vector_layer], view: new ol.View({ center: [0, 0], zoom: 2 }) });

Any idea how this could/should be done?

I am using:

  • Angular 4.0.0
  • OpenLayers 4.1.1
2 Answers
Related