Skip to content

Commit

Permalink
Google Map: Center info window arrow on marker icon
Browse files Browse the repository at this point in the history
  • Loading branch information
iandunn committed Oct 13, 2023
1 parent 6456a77 commit f605ad7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion mu-plugins/blocks/google-map/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ function render( $attributes, $content, $block ) {

$attributes['markerIcon'] = array(
'markerUrl' => plugins_url( 'images/map-marker.svg', __FILE__ ),
'markerAnchorXOffset' => 34,
'markerHeight' => 68,
'markerWidth' => 68,
'markerAnchorYOffset' => -5,
'clusterUrl' => plugins_url( 'images/cluster-background.svg', __FILE__ ),
'clusterWidth' => 38,
'clusterHeight' => 38,
);

$attributes['markerIcon']['markerAnchorXOffset'] = $attributes['markerIcon']['markerWidth'] / -4;

wp_add_inline_script(
$block->block_type->view_script_handles[0],
sprintf(
Expand Down
3 changes: 1 addition & 2 deletions mu-plugins/blocks/google-map/src/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ export default function Map( { apiKey, markers: rawMarkers, icon } ) {

googleMap.current = map;
googleMapsApi.current = maps;

infoWindow.current = new maps.InfoWindow( {
pixelOffset: new maps.Size( -icon.markerIconAnchorXOffset, 0 ),
pixelOffset: new maps.Size( icon.markerAnchorXOffset, icon.markerAnchorYOffset ),
} );

combinedMarkers = combineDuplicateLocations( rawMarkers );
Expand Down

0 comments on commit f605ad7

Please sign in to comment.