Skip to content

Commit

Permalink
Autozoom when there are multiple values (!! no UI for this yet !!)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoryHogeveen committed Dec 6, 2017
1 parent 1267057 commit 8ea91bf
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions components/Maps/ui/front/map-google.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
$value = array( $value );
$multiple = false;
}

foreach( $value as $key => $val ) {

$val = wp_parse_args( $val, array(
Expand Down Expand Up @@ -258,15 +257,17 @@ class="pods-maps-map-canvas pods-<?php echo $type ?>-maps-map-canvas"
map.panToBounds( bounds );
mapOptions.center = map.getCenter();

//(optional) restore the zoom level after the map is done scaling
/*var listener = google.maps.event.addListener( map, "idle", function () {
map.setZoom( mapOptions.zoom );
google.maps.event.removeListener( listener );
} );*/
var listener = google.maps.event.addListener( map, "idle", function () {
// If the current zoom is higher than the original zoom (due to fitBounds) set it to the original.
if ( map.getZoom() > mapOptions.zoom ) {
map.setZoom( mapOptions.zoom );
google.maps.event.removeListener( listener );
}
} );

} else {
map.setCenter( mapOptions.center );
}

} ); // end document ready
</script>
</script>

0 comments on commit 8ea91bf

Please sign in to comment.