'https://schema.org', '@type' => 'Map', 'name' => !empty($attributes['title']) ? $attributes['title'] : 'Location Map', 'description' => !empty($attributes['description']) ? $attributes['description'] : 'Interactive Google Map showing location details', ); if (!empty($attributes['markers'])) { $schema['hasMap'] = array(); foreach ($attributes['markers'] as $marker) { $place = array( '@type' => 'Place', 'geo' => array( '@type' => 'GeoCoordinates', 'latitude' => $marker['latitude'], 'longitude' => $marker['longitude'] ) ); if (!empty($marker['title'])) { $place['name'] = $marker['title']; } if (!empty($marker['description'])) { $place['description'] = $marker['description']; } if (!empty($marker['address'])) { $place['address'] = array( '@type' => 'PostalAddress', 'streetAddress' => $marker['address'] ); } $schema['hasMap'][] = $place; } } return $schema; } /** * Output schema markup in the footer */ public function output_schema() { global $post; if (!is_singular() || !has_blocks($post->post_content)) { return; } $blocks = parse_blocks($post->post_content); $schemas = array(); foreach ($blocks as $block) { if ($block['blockName'] === 'xero/google-map') { $schemas[] = $this->generate_schema($block['attrs']); } } if (!empty($schemas)) { echo ''; } } } // Initialize the schema handler new XeroGoogleMapSchema();