settings->gmaps_key; // Short circuit if missing key or ride object doesn't have the data we need. if ( empty( $key ) || empty( $ride->map ) ) { return ''; } $url = "https://maps.googleapis.com/maps/api/staticmap?maptype=terrain&size={$width}x{$height}&sensor=false&key={$key}&path=color:0xFF0000BF|weight:2|enc:"; $url_len = strlen( $url ); $max_chars = 1865; if ( ! empty( $ride->map->polyline ) && ( $url_len + strlen( $ride->map->polyline ) < $max_chars ) ) { $url .= $ride->map->polyline; } elseif ( ! empty( $ride->map->summary_polyline ) ) { $url .= $ride->map->summary_polyline; } return ""; } }