Pass node field value to view filter in a block Background

For the node type article I want to display a block view of map markers generated from a content type called sted (places). For the content type article I have made a entity reference field (multiple values allowed) called kartreferanse (map reference) where you can pick multiple nodes of the type sted (places). So far so good. I have also made a view in a block that displays markers for all the content types sted (places) using a Geolocation - CommonMap. Now I want to pass the reference field to the view to show only the places picked in the field kartreferanse (map reference) for the current node. I have tried using contextual filters (field_kartreferanse: Content) Content: ID with no luck, and/or tried building a relationship using field_kartreferanse: Content in the view.

The question

How can i pass the ID of the current node (article) to the view (in a block) and use the entity reference field in the article to show right node IDs in the map block view?
Do I also have to make some filter-criteria for this to work? (field_kartreferanse: Content) Innhold: ID (= [Content: Nid])
(Later I will have to make this view work in a multilingual site.)



(Drupal 8, local install / mamp, geo locationfield, views 8.1.10)
The easiest way to use a view in a block (or anything that uses a build array) is as a render element:

$node = \Drupal::routeMatch()-&gt;getParameter('node');

$current_nid = $node-&gt;id();

$view_arguments = [$current_nid];

 $build['news'] = [
   '#type' =&gt; 'view',
   '#name' =&gt; 'myviewname',
   '#display_id' =&gt; 'block_1',
   '#arguments' =&gt; $view_arguments,
   '#weight' =&gt; 30,
 ];

return $build;


The first argument passed in will be used as your content ID.

If you want to do it all through the UI, you set your contextual filter to pull from the content id.



then if you place a block based on the view, it will pull in from the current node.