function geofield_map_googlemap_render in Geofield Map 8
Same name and namespace in other branches
- 8.2 geofield_map.module \geofield_map_googlemap_render()
Load all Geofield Google Map client files and return markup for a map.
Parameters
array $js_settings: The map rendering data.
Return value
array The returned render array.
2 calls to geofield_map_googlemap_render()
- GeofieldGoogleMapFormatter::viewElements in src/Plugin/ Field/ FieldFormatter/ GeofieldGoogleMapFormatter.php 
- Builds a renderable array for a field value.
- GeofieldGoogleMapViewStyle::render in src/Plugin/ views/ style/ GeofieldGoogleMapViewStyle.php 
- Renders the View.
File
- ./geofield_map.module, line 60 
- Contains the geofield_map.module.
Code
function geofield_map_googlemap_render(array $js_settings) {
  $render_array = [
    '#theme' => 'geofield_google_map',
    '#mapid' => $js_settings['mapid'],
    '#height' => $js_settings['map_settings']['map_dimensions']['height'],
    '#width' => $js_settings['map_settings']['map_dimensions']['width'],
    '#attached' => [
      'library' => [
        'geofield_map/geojson',
        'geofield_map/geofield_gmap',
      ],
      'drupalSettings' => [
        'geofield_google_map' => [
          $js_settings['mapid'] => $js_settings,
        ],
      ],
    ],
    '#cache' => [
      'contexts' => [
        'url.path',
        'url.query_args',
      ],
    ],
  ];
  // Add the Marker Cluster library, if asked.
  if ($js_settings['map_settings']['map_markercluster']['markercluster_control']) {
    $render_array['#attached']['library'][] = 'geofield_map/marker_cluster';
  }
  // Add the OverlappingMarkerSpiderfier library, if asked.
  if (!isset($js_settings['map_settings']['map_oms']['map_oms_control']) || $js_settings['map_settings']['map_oms']['map_oms_control']) {
    $render_array['#attached']['library'][] = 'geofield_map/overlappingmarkerspiderfier';
  }
  return $render_array;
}