array( array( 'featureType' => 'all', 'elementType' => 'all', 'stylers' => array( array('saturation' => '32'), array('lightness' => '-3'), array('visibility' => 'on'), array('weight' => '1.18'), ), ), array( 'featureType' => 'administrative', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'landscape', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'landscape.man_made', 'elementType' => 'all', 'stylers' => array( array('saturation' => '-70'), array('lightness' => '14'), ), ), array( 'featureType' => 'poi', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'road', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'transit', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'water', 'elementType' => 'all', 'stylers' => array( array('saturation' => '100'), array('lightness' => '-14'), ), ), array( 'featureType' => 'water', 'elementType' => 'labels', 'stylers' => array( array('visibility' => 'off'), array('lightness' => '12'), ), ), ), 'light' => array( array( 'featureType' => 'administrative', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'on')), ), array( 'featureType' => 'administrative.country', 'elementType' => 'geometry.stroke', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'administrative.province', 'elementType' => 'geometry.stroke', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'landscape', 'elementType' => 'geometry', 'stylers' => array( array('visibility' => 'on'), array('color' => '#e3e3e3'), ), ), array( 'featureType' => 'landscape.natural', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'on')), ), array( 'featureType' => 'poi', 'elementType' => 'all', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'road', 'elementType' => 'all', 'stylers' => array(array('color' => '#cccccc')), ), array( 'featureType' => 'road', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'transit', 'elementType' => 'labels.icon', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'transit.line', 'elementType' => 'geometry', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'transit.line', 'elementType' => 'labels.text', 'stylers' => array(array('visibility' => 'on')), ), array( 'featureType' => 'transit.station.airport', 'elementType' => 'geometry', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'transit.station.airport', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'on')), ), array( 'featureType' => 'water', 'elementType' => 'geometry', 'stylers' => array(array('color' => '#FFFFFF')), ), array( 'featureType' => 'water', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'on')), ), ), 'dark' => array( array( 'featureType' => 'all', 'elementType' => 'labels.text.fill', 'stylers' => array( array('saturation' => 36), array('color' => '#707070'), array('lightness' => 40), ), ), array( 'featureType' => 'all', 'elementType' => 'labels.text.stroke', 'stylers' => array( array('visibility' => 'on'), array('color' => '#000000'), array('lightness' => 16), ), ), array( 'featureType' => 'all', 'elementType' => 'labels.icon', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'administrative', 'elementType' => 'geometry.fill', 'stylers' => array( array('color' => '#000000'), array('lightness' => 20), ), ), array( 'featureType' => 'administrative', 'elementType' => 'geometry.stroke', 'stylers' => array( array('color' => '#000000'), array('lightness' => 17), array('weight' => 1.2), ), ), array( 'featureType' => 'landscape', 'elementType' => 'geometry', 'stylers' => array(array('color' => '#424242')), ), array( 'featureType' => 'poi', 'elementType' => 'geometry', 'stylers' => array( array('color' => '#000000'), array('lightness' => 21), ), ), array( 'featureType' => 'poi', 'elementType' => 'labels', 'stylers' => array(array('visibility' => 'on')), ), array( 'featureType' => 'poi', 'elementType' => 'labels.icon', 'stylers' => array(array('visibility' => 'off')), ), array( 'featureType' => 'road.highway', 'elementType' => 'geometry.fill', 'stylers' => array( array('lightness' => 17), array('color' => '#484848'), ), ), array( 'featureType' => 'road.highway', 'elementType' => 'geometry.stroke', 'stylers' => array( array('lightness' => 29), array('weight' => 0.2), array('color' => '#ff0000'), array('visibility' => 'off'), ), ), array( 'featureType' => 'road.arterial', 'elementType' => 'geometry', 'stylers' => array( array('color' => '#000000'), array('lightness' => 18), ), ), array( 'featureType' => 'road.local', 'elementType' => 'geometry', 'stylers' => array( array('color' => '#000000'), array('lightness' => 16), ), ), array( 'featureType' => 'transit', 'elementType' => 'geometry', 'stylers' => array( array('color' => '#000000'), array('lightness' => 19), ), ), array( 'featureType' => 'water', 'elementType' => 'geometry', 'stylers' => array( array('color' => '#000000'), array('lightness' => 17), ), ), ), 'pale_dawn' => array( array( 'featureType' => 'administrative', 'elementType' => 'all', 'stylers' => array( array('visibility' => 'on'), array('lightness' => 33), ), ), array( 'featureType' => 'landscape', 'elementType' => 'all', 'stylers' => array(array('color' => '#f2e5d4')), ), array( 'featureType' => 'poi.park', 'elementType' => 'geometry', 'stylers' => array(array('color' => '#c5dac6')), ), array( 'featureType' => 'poi.park', 'elementType' => 'labels', 'stylers' => array( array('visibility' => 'on'), array('lightness' => 20), ), ), array( 'featureType' => 'road', 'elementType' => 'all', 'stylers' => array(array('lightness' => 20)), ), array( 'featureType' => 'road.highway', 'elementType' => 'geometry', 'stylers' => array(array('color' => '#c5c6c6')), ), array( 'featureType' => 'road.arterial', 'elementType' => 'geometry', 'stylers' => array(array('color' => '#e4d7c6')), ), array( 'featureType' => 'road.local', 'elementType' => 'geometry', 'stylers' => array(array('color' => '#fbfaf7')), ), array( 'featureType' => 'water', 'elementType' => 'all', 'stylers' => array( array('visibility' => 'on'), array('color' => '#acbcc9'), ), ), ), ); $xero_google_map_block_id = $attributes['blockId'] ?? ''; $xero_google_map_api_key = get_option('wpxero_google_maps_api_key', ''); // No API key: render the exact same static iframe embed `save.js` produces. if (empty($xero_google_map_api_key)) { $xero_google_map_location = $attributes['location'] ?? 'New York, NY, USA'; $xero_google_map_zoom_attr = $attributes['zoom'] ?? null; $xero_google_map_zoom = is_array($xero_google_map_zoom_attr) ? ($xero_google_map_zoom_attr['value'] ?? 8) : ($xero_google_map_zoom_attr ?: 8); $xero_google_map_lang = $attributes['language'] ?? 'en'; $xero_google_map_type = $attributes['mapType'] ?? 'm'; $xero_google_map_lat = $attributes['latitude'] ?? null; $xero_google_map_lng = $attributes['longitude'] ?? null; $xero_google_map_center = ($xero_google_map_lat && $xero_google_map_lng) ? "{$xero_google_map_lat},{$xero_google_map_lng}" : '40.7128,-74.0060'; $xero_google_map_url = 'https://maps.google.com/maps?' . http_build_query(array( 'q' => $xero_google_map_location ?: 'New York', 'z' => $xero_google_map_zoom, 'output' => 'embed', 'language' => $xero_google_map_lang, 't' => $xero_google_map_type, 'markers' => $xero_google_map_center, 'hl' => $xero_google_map_lang, 'center' => $xero_google_map_center, )); $xero_google_map_no_api_style = $attributes['noApiStyle'] ?? array(); $xero_google_map_height = $xero_google_map_no_api_style['desktop']['height'] ?? ($attributes['height'] ?? 400); $xero_google_map_wrapper_attrs = get_block_wrapper_attributes(array( 'id' => $xero_google_map_block_id ? "wpxero-{$xero_google_map_block_id}" : null, 'class' => 'xero-google-map', 'style' => 'box-sizing:border-box;', )); ?>
>
$xero_google_map_marker['lat'] ?? null, 'lng' => $xero_google_map_marker['lng'] ?? null, 'title' => $xero_google_map_marker['title'] ?? '', 'infoWindowText' => $xero_google_map_marker['infoWindowText'] ?? '', 'iconUrl' => $xero_google_map_has_icon ? $xero_google_map_marker['iconImageURL'] : null, 'iconWidth' => $xero_google_map_has_icon ? $xero_google_map_marker['iconImageCustomWidth'] : null, 'iconHeight' => $xero_google_map_has_icon ? $xero_google_map_marker['iconImageCustomWidth'] * ($xero_google_map_marker['iconImageHeight'] / $xero_google_map_marker['iconImageWidth']) : null, 'category' => $xero_google_map_marker['category'] ?? '', ); } $xero_google_map_categories = array(); foreach ($attributes['categories'] ?? array() as $xero_google_map_category) { if (empty($xero_google_map_category['id'])) { continue; } $xero_google_map_categories[] = array( 'id' => (string) $xero_google_map_category['id'], 'label' => $xero_google_map_category['label'] ?? '', 'color' => $xero_google_map_category['color'] ?? '#4285F4', ); } $xero_google_map_show_list = !empty($attributes['showMarkerList']) && !empty($xero_google_map_markers); $xero_google_map_list_position = in_array($attributes['markerListPosition'] ?? 'below', array('below', 'side'), true) ? $attributes['markerListPosition'] : 'below'; $xero_google_map_wrapper_attrs = get_block_wrapper_attributes(array( 'id' => $xero_google_map_block_id ? "wpxero-{$xero_google_map_block_id}" : null, 'class' => 'xero-google-map' . (!empty($attributes['fullHeight']) ? ' xero-google-map-fullheight' : ''), 'data-lat' => $attributes['lat'] ?? 40.7127753, 'data-lng' => $attributes['lng'] ?? -74.0059728, 'data-zoom' => $xero_google_map_zoom, 'data-show-zoom-buttons' => !empty($attributes['showZoomButtons']) ? 'true' : 'false', 'data-show-map-type-buttons' => !empty($attributes['showMapTypeButtons']) ? 'true' : 'false', 'data-show-street-view-button' => !empty($attributes['showStreetViewButton']) ? 'true' : 'false', 'data-show-fullscreen-button' => !empty($attributes['showFullscreenButton']) ? 'true' : 'false', 'data-option-scroll-wheel' => !empty($attributes['optionScrollWheel']) ? 'true' : 'false', 'data-option-draggable' => !empty($attributes['optionDraggable']) ? 'true' : 'false', 'data-gesture-handling' => $attributes['gestureHandling'] ?? 'greedy', 'data-styles' => wp_json_encode($xero_google_map_styles, JSON_INVALID_UTF8_SUBSTITUTE), 'data-markers' => wp_json_encode($xero_google_map_markers, JSON_INVALID_UTF8_SUBSTITUTE), 'data-show-filters' => (!empty($attributes['showFilters']) && !empty($xero_google_map_categories)) ? 'true' : 'false', 'data-categories' => wp_json_encode($xero_google_map_categories, JSON_INVALID_UTF8_SUBSTITUTE), 'data-show-directions' => !empty($attributes['showDirections']) ? 'true' : 'false', 'data-directions-travel-mode' => $attributes['directionsTravelMode'] ?? 'DRIVING', 'data-layer-traffic' => !empty($attributes['layerTraffic']) ? 'true' : 'false', 'data-layer-transit' => !empty($attributes['layerTransit']) ? 'true' : 'false', 'data-layer-bicycling' => !empty($attributes['layerBicycling']) ? 'true' : 'false', 'data-show-marker-list' => $xero_google_map_show_list ? 'true' : 'false', )); // Localize the block's own view script with the API key/URL — this is the // one PHP location that's guaranteed to run exactly when the block is // actually output, so it doesn't need a separate parse_blocks() scan. // Uses a dedicated global name (not `WPXERO`) because `wp_localize_script` // assigns `var WPXERO = {...}` rather than merging — the front end also // localizes an unrelated `wpxero-helper` script under the same `WPXERO` // name (timezone/ajax_url/nonce), and whichever inline script prints later // in the page silently overwrites the other, wiping out the API key. foreach ($block->block_type->view_script_handles ?? array() as $xero_google_map_view_handle) { wp_localize_script($xero_google_map_view_handle, 'WPXEROGoogleMaps', array( 'googleMapsAPIKey' => $xero_google_map_api_key, 'googleMapsAPIUrl' => 'https://maps.googleapis.com/maps/api/js?libraries=geometry,drawing,places', )); } // When wrapped for Marker List View, the wide/full alignment class WP core // applies to the wrapper (via `get_block_wrapper_attributes()`'s align // support) needs to also land on this outer layout div — themes commonly // style alignment with a direct-child selector like `.entry-content > // .alignwide`, which would otherwise stop matching once the map is no // longer a direct child of the content column. $xero_google_map_align_class = ''; if (!empty($attributes['align']) && in_array($attributes['align'], array('wide', 'full'), true)) { $xero_google_map_align_class = ' align' . $attributes['align']; } ?>
>