mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-20 07:04:24 +09:00
Formatting
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
class WPStrava_StaticMap {
|
class WPStrava_StaticMap {
|
||||||
|
|
||||||
private static $MAX_CHARS = 1865;
|
private static $max_chars = 1865;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an image tag to a static google map. Will render with
|
* Get an image tag to a static google map. Will render with
|
||||||
@@ -31,11 +31,11 @@ class WPStrava_StaticMap {
|
|||||||
$width = 480;
|
$width = 480;
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = "https://maps.googleapis.com/maps/api/staticmap?maptype=terrain&size={$width}x{$height}&scale=2&sensor=false&key={$key}&path=color:0xFF0000BF|weight:2|enc:";
|
$url = "https://maps.googleapis.com/maps/api/staticmap?maptype=terrain&size={$width}x{$height}&scale=2&sensor=false&key={$key}&path=color:0xFF0000BF|weight:2|enc:";
|
||||||
$url_len = strlen( $url );
|
$url_len = strlen( $url );
|
||||||
|
|
||||||
$polyline = '';
|
$polyline = '';
|
||||||
if ( ! empty( $activity->map->polyline ) && ( $url_len + strlen( $activity->map->polyline ) < self::$MAX_CHARS ) ) {
|
if ( ! empty( $activity->map->polyline ) && ( $url_len + strlen( $activity->map->polyline ) < self::$max_chars ) ) {
|
||||||
$polyline = $activity->map->polyline;
|
$polyline = $activity->map->polyline;
|
||||||
} elseif ( ! empty( $activity->map->summary_polyline ) ) {
|
} elseif ( ! empty( $activity->map->summary_polyline ) ) {
|
||||||
$polyline = $activity->map->summary_polyline;
|
$polyline = $activity->map->summary_polyline;
|
||||||
@@ -109,7 +109,7 @@ class WPStrava_StaticMap {
|
|||||||
$points = Polyline::flatten( $points );
|
$points = Polyline::flatten( $points );
|
||||||
$polyline = Polyline::encode( $points );
|
$polyline = Polyline::encode( $points );
|
||||||
|
|
||||||
if ( $url_len + strlen( $polyline ) >= self::$MAX_CHARS ) {
|
if ( $url_len + strlen( $polyline ) >= self::$max_chars ) {
|
||||||
// Reduce again.
|
// Reduce again.
|
||||||
$polyline = self::reduce_polyline( $url_len, $polyline );
|
$polyline = self::reduce_polyline( $url_len, $polyline );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user