public function getPins($type, $id = NULL) {
    if ($id) {
      $location_ids[] = $id;
    }
    else {
      $location_ids = $this->queryFactory->get('node')
        ->condition('type', $type)
        ->condition('status', 1)
        ->execute();
    }

    if (!$location_ids) {
      return [];
    }

    $storage = $this->entityTypeManager->getStorage('node');
    $builder = $this->entityTypeManager->getViewBuilder('node');
    $locations = $storage->loadMultiple($location_ids);

    // Get labels and icons for every bundle from OpenY Map config.
    $typeIcons = $this->configFactory->get('openy_map.settings')->get('type_icons');
    $typeLabels = $this->configFactory->get('openy_map.settings')->get('type_labels');
    $tag = $typeLabels[$type];
    $pins = [];
    foreach ($locations as $location) {
      $view = $builder->view($location, 'teaser');
      $coordinates = $location->get('field_location_coordinates')->getValue();
      if (!$coordinates) {
        continue;
      }
      $uri = !empty($typeIcons[$location->bundle()]) ? $typeIcons[$location->bundle()] :
        '/' . drupal_get_path('module', 'openy_map') . "/img/map_icon_green.png";
      $pins[] = [
        'icon' => $uri,
        'tags' => [$tag],
        'lat' => round($coordinates[0]['lat'], 5),
        'lng' => round($coordinates[0]['lng'], 5),
        'name' => $location->label(),
        'markup' => $this->renderer->renderRoot($view),
      ];
    }

    return $pins;
  }
public function getPins($type, $id = NULL) {
    if ($id) {
      $location_ids[] = $id;
    }
    else {
      $location_ids = $this->queryFactory->get('node')
        ->condition('type', $type)
        ->condition('status', 1)
        ->execute();
    }

    if (!$location_ids) {
      return [];
    }

    $storage = $this->entityTypeManager->getStorage('node');
    $builder = $this->entityTypeManager->getViewBuilder('node');
    $locations = $storage->loadMultiple($location_ids);

    // Get labels and icons for every bundle from OpenY Map config.
    $typeIcons = $this->configFactory->get('openy_map.settings')->get('type_icons');
    $typeLabels = $this->configFactory->get('openy_map.settings')->get('type_labels');
    $tag = $typeLabels[$type];
    $pins = [];
    foreach ($locations as $location) {
      $view = $builder->view($location, 'teaser');
      $coordinates = $location->get('field_location_coordinates')->getValue();
      if (!$coordinates) {
        continue;
      }
      $uri = !empty($typeIcons[$location->bundle()]) ? $typeIcons[$location->bundle()] :
        '/' . drupal_get_path('module', 'openy_map') . "/img/map_icon_green.png";
      $pins[] = [
        'icon' => $uri,
        'tags' => [$tag],
        'lat' => round($coordinates[0]['lat'], 5),
        'lng' => round($coordinates[0]['lng'], 5),
        'name' => $location->label(),
        'markup' => $this->renderer->renderRoot($view),
      ];
    }

    return $pins;
  }
public function getPins ( $ type , $ id = NULL ) { if ( $ id ) { $ location_ids [ ] = $ id ; } else { $ location_ids = $ this -> queryFactory -> get ( 'node' ) -> condition ( 'type' , $ type ) -> condition ( 'status' , 1 ) -> execute ( ) ; } if ( ! $ location_ids ) { return [ ] ; } $ storage = $ this -> entityTypeManager -> getStorage ( 'node' ) ; $ builder = $ this -> entityTypeManager -> getViewBuilder ( 'node' ) ; $ locations = $ storage -> loadMultiple ( $ location_ids ) ; // Get labels and icons for every bundle from OpenY Map config. $ typeIcons = $ this -> configFactory -> get ( 'openy_map.settings' ) -> get ( 'type_icons' ) ; $ typeLabels = $ this -> configFactory -> get ( 'openy_map.settings' ) -> get ( 'type_labels' ) ; $ tag = $ typeLabels [ $ type ] ; $ pins = [ ] ; foreach ( $ locations as $ location ) { $ view = $ builder -> view ( $ location , 'teaser' ) ; $ coordinates = $ location -> get ( 'field_location_coordinates' ) -> getValue ( ) ; if ( ! $ coordinates ) { continue ; } $ uri = ! empty ( $ typeIcons [ $ location -> bundle ( ) ] ) ? $ typeIcons [ $ location -> bundle ( ) ] : '/' . drupal_get_path ( 'module' , 'openy_map' ) . "/img/map_icon_green.png" ; $ pins [ ] = [ 'icon' => $ uri , 'tags' => [ $ tag ] , 'lat' => round ( $ coordinates [ 0 ] [ 'lat' ] , 5 ) , 'lng' => round ( $ coordinates [ 0 ] [ 'lng' ] , 5 ) , 'name' => $ location -> label ( ) , 'markup' => $ this -> renderer -> renderRoot ( $ view ) , ] ; } return $ pins ; }
Get pins.

@param string $type
Location node type (branch, camp or facility).
@param int $id
Node ID (if set return pin only for specified node ID).

@return array
Pins.
Get pins .