Embed::map
Get the HTML of a Google map as the editor writes it
Description
public static string Embed::map( string $pasted, [ array $options = array() ] )
Returns the block the editor writes for a map, or '' when $pasted is not a Google Maps embed (the <iframe> of "Share" > "Embed a map", or its URL). The template modifier feggMap calls this method.
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $pasted | string | The <iframe> of Google Maps, or its URL | |
| $options | array | array() | ratio ('4-3', '16-9', '1-1'), align, width (see Options) |
Example
Controller
use Fegg\Tool\Embed;
echo Embed::map('https://www.google.com/maps/embed?pb=!1m18!1m12');
// <div class="fegg-map"><iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12" title="地図" loading="lazy" referrerpolicy="no-referrer-when-downgrade" allowfullscreen></iframe></div>
echo Embed::map($pasted, array('ratio' => '16-9', 'align' => 'right', 'width' => 80));
// <div class="fegg-map is-16-9 alignright" style="width: 80%"><iframe ...></iframe></div>
Template
{{ $page.data.map|feggMap|noescape }}
{{ $page.data.map|feggMap:'16-9':'center':80|noescape }}