The googlemap virtual field uses Google Maps JavaScript to display a Map.
It doesn't work in the Fields meta box displayed in the new block editor.
Expected output - Classic editor
When displayed using the Classic editor the Google Maps Map is correctly displayed
Actual output - Block editor
When the field is displayed in a meta box controlled by the new block editor the field is not displayed.
The following message appears in the console log
post.php?post=962&action=edit:505 Uncaught ReferenceError: google is not defined
at initialize1 (post.php?post=962&action=edit:505)
initialize1 @ post.php?post=962&action=edit:505
load (async)
(anonymous) @ post.php?post=962&action=edit:505
Explanation
The bw_fields_get_google_map function uses the Google Maps logic developed for the [bw_show_googlemap] shortcode.
oik_require( "shortcodes/oik-googlemap.php" );
$google_map = bw_googlemap_v3( get_the_title( $ID )
, $lat
, $long
, $post_code
, "100%"
, "400px"
);
The block editor expands the content during REST API processing. This causes the logic to increment a counter which is used to determine whether or not the Google initialisation code is required.
We need to ensure that the meta box enqueues the script.
Proposed solution
Insert the following line between the oik_require and bw_googlemap_v3 calls.
The
googlemapvirtual field uses Google Maps JavaScript to display a Map.It doesn't work in the Fields meta box displayed in the new block editor.
Expected output - Classic editor
When displayed using the Classic editor the Google Maps Map is correctly displayed
Actual output - Block editor
When the field is displayed in a meta box controlled by the new block editor the field is not displayed.
The following message appears in the console log
Explanation
The
bw_fields_get_google_mapfunction uses the Google Maps logic developed for the[bw_show_googlemap]shortcode.The block editor expands the content during REST API processing. This causes the logic to increment a counter which is used to determine whether or not the Google initialisation code is required.
We need to ensure that the meta box enqueues the script.
Proposed solution
Insert the following line between the oik_require and bw_googlemap_v3 calls.