Skip to content

Commit

Permalink
Include the Google v3 client key in static map URLs, fixes #755
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhobo committed Sep 11, 2016
1 parent 7ffa5b3 commit 591e858
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion geo-mashup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,7 @@ private static function add_map_content_attributes( array $atts ) {
* @return mixed|string|void
*/
private static function build_map_image( &$atts, $map_data, $click_to_load, $click_to_load_text ) {
global $geo_mashup_options;

// Static maps have a limit of 50 markers: http://code.google.com/apis/maps/documentation/staticmaps/#Markers
$atts['limit'] = empty( $atts['limit'] ) ? 50 : $atts['limit'];
Expand All @@ -1258,8 +1259,9 @@ private static function build_map_image( &$atts, $map_data, $click_to_load, $cli
return '';
}

$key = $geo_mashup_options->get( 'overall', 'googlev3_key' );
$dimensions = intval( $map_data['width'] ) . 'x' . intval( $map_data['height'] );
$map_image = '<img src="http://maps.google.com/maps/api/staticmap?size=' . $dimensions;
$map_image = '<img src="http://maps.google.com/maps/api/staticmap?size=' . $dimensions . '&amp;key=' . $key;
if ( count( $map_data['object_data']['objects'] ) == 1) {
$map_image .= '&amp;center=' . $map_data['object_data']['objects'][0]['lat'] . ',' .
$map_data['object_data']['objects'][0]['lng'];
Expand Down

0 comments on commit 591e858

Please sign in to comment.