Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -44,9 +44,11 @@ class _Google
|
||||
* @param int $width Width
|
||||
* @param int $height Height
|
||||
* @param float|NULL $zoom The zoom amount (a value between 0 being totally zoomed out view of the world, and 1 being as fully zoomed in as possible) or NULL to zoom automatically based on how much data is available
|
||||
* @param int $scale Google maps scale to use (https://developers.google.com/maps/documentation/static-maps/intro#scale_values)
|
||||
* @param string $maptype Type of map to use. Valid values are roadmap (default), satellite, terrain, and hybrid (https://developers.google.com/maps/documentation/static-maps/intro#MapTypes)
|
||||
* @return string
|
||||
*/
|
||||
public function render( $width, $height, $zoom=NULL )
|
||||
public function render( $width, $height, $zoom=NULL, $scale=1, $maptype='roadmap' )
|
||||
{
|
||||
if ( $this->geolocation->lat and $this->geolocation->long )
|
||||
{
|
||||
@@ -84,11 +86,12 @@ class _Google
|
||||
'center' => $location,
|
||||
'zoom' => $zoom === NULL ? NULL : ceil( $zoom * 8 ),
|
||||
'size' => "{$width}x{$height}",
|
||||
'sensor' => 'false',
|
||||
'markers' => $location,
|
||||
'key' => \IPS\Settings::i()->google_maps_api_key,
|
||||
'scale' => $scale,
|
||||
'maptype' => $maptype
|
||||
) );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->googleMap( $linkUrl, $imageUrl, $this->geolocation->lat, $this->geolocation->long );
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->staticMap( $linkUrl, $imageUrl, $this->geolocation->lat, $this->geolocation->long );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Mapbox Maps
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 2 Nov 2017
|
||||
*/
|
||||
|
||||
namespace IPS\GeoLocation\Maps;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapbox Maps
|
||||
*/
|
||||
class _Mapbox
|
||||
{
|
||||
/**
|
||||
* @brief GeoLocation
|
||||
*/
|
||||
public $geoLocation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\GeoLocation $geoLocation Location
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\GeoLocation $geoLocation )
|
||||
{
|
||||
$this->geolocation = $geoLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render
|
||||
*
|
||||
* @param int $width Width
|
||||
* @param int $height Height
|
||||
* @param float|NULL $zoom The zoom amount (a value between 0 being totally zoomed out view of the world, and 1 being as fully zoomed in as possible) or NULL to zoom automatically based on how much data is available
|
||||
* @return string
|
||||
*/
|
||||
public function render( $width, $height, $zoom=NULL )
|
||||
{
|
||||
if( !($this->geolocation->long and $this->geolocation->lat ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
$location = $this->geolocation->long . ',' . $this->geolocation->lat;
|
||||
|
||||
$imageUrl = \IPS\Http\Url::external( "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/pin-l-marker+f00({$location})/{$location},14,0,60/{$width}x{$height}@2x" )->setQueryString( array(
|
||||
'access_token' => \IPS\Settings::i()->mapbox_api_key,
|
||||
) );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->staticMap( NULL, $imageUrl, $this->geolocation->lat, $this->geolocation->long );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user