Class Socialveo\Core\helpers\MapHelper

InheritanceSocialveo\Core\helpers\MapHelper

Class MapHelper

Public Methods

Hide inherited methods

MethodDescriptionDefined By
bestZoomForDistance() Calculate best zoom for distance Socialveo\Core\helpers\MapHelper
calcPointsRange() Calculate points range Socialveo\Core\helpers\MapHelper
convertDistance() Convert distance to measure Socialveo\Core\helpers\MapHelper
createStaticMapUrl() Create static map and sign it Socialveo\Core\helpers\MapHelper
destinationPoint() Returns the destination point from ‘this’ point having travelled the given distance on the given initial bearing (bearing normally varies around path followed). Socialveo\Core\helpers\MapHelper
getDistanceMeasure() Parse distance and measure from string Socialveo\Core\helpers\MapHelper
getGMapCircle() Create encoded polyline of circle for google maps Socialveo\Core\helpers\MapHelper
haversineDistance() Calculates the great-circle distance between two points, with the Haversine formula. Socialveo\Core\helpers\MapHelper
normalizeAngle() Normalise angle to −180. Socialveo\Core\helpers\MapHelper
pointRanges() Get point ranges Socialveo\Core\helpers\MapHelper
vincentyDistance() Calculates the great-circle distance between two points, with the Vincenty formula. Socialveo\Core\helpers\MapHelper

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
EARTH_RADIUS_KM 6371.3 Socialveo\Core\helpers\MapHelper
EARTH_RADIUS_METERS 6371300 Socialveo\Core\helpers\MapHelper
EARTH_RADIUS_MILES 3959 Socialveo\Core\helpers\MapHelper
KM 'km' Socialveo\Core\helpers\MapHelper
KM2MILES 0.62137119224 Socialveo\Core\helpers\MapHelper
METERS 'm' Socialveo\Core\helpers\MapHelper
MILES 'ml' Socialveo\Core\helpers\MapHelper
MILES2KM 1.609344 Socialveo\Core\helpers\MapHelper

Method Details

bestZoomForDistance() public static method

Calculate best zoom for distance

public static integer bestZoomForDistance ( $pixels, $distance )
$pixels integer
$distance string|mixed
calcPointsRange() public static method

Calculate points range

public static array calcPointsRange ( $lat, $lng, $dist )
$lat float

Latitude of center point in [deg decimal]

$lng float

Longitude of center point in [deg decimal]

$dist integer|float

The radius of distance between 2 points

convertDistance() public static method

Convert distance to measure

public static \Socialveo\Core\helpers\numeric convertDistance ( $distance, $toMeasure )
$distance string
$toMeasure string
createStaticMapUrl() public static method

Create static map and sign it

public static string createStaticMapUrl ( $params = [] )
$params array

[optional]

destinationPoint() public static method

Returns the destination point from ‘this’ point having travelled the given distance on the given initial bearing (bearing normally varies around path followed).

public static array destinationPoint ( $lat, $lng, $distance, $bearing )
$lat float

Latitude of center point in [deg decimal]

$lng float

Longitude of center point in [deg decimal]

$distance integer|float

The radius of distance between 2 points (kilometers)

$bearing float
getDistanceMeasure() public static method

Parse distance and measure from string

public static array getDistanceMeasure ( $distance )
$distance string
return array

[Distance, Measure]

getGMapCircle() public static method

Create encoded polyline of circle for google maps

public static string getGMapCircle ( $lat, $lng, $radius, $detail 8 )
$lat float
$lng float
$radius string

Radius of our circle (in Kilometres)

$detail integer

[optional]

haversineDistance() public static method

Calculates the great-circle distance between two points, with the Haversine formula.

public static float haversineDistance ( $latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $unit self::KM )
$latitudeFrom float

Latitude of start point in [deg decimal]

$longitudeFrom float

Longitude of start point in [deg decimal]

$latitudeTo float

Latitude of target point in [deg decimal]

$longitudeTo float

Longitude of target point in [deg decimal]

$unit string

[optional] Unit

return float

Distance between points in [m] (same as earthRadius)

normalizeAngle() public static method

Normalise angle to −180.

.+180°

public static integer|float normalizeAngle ( $angle )
$angle integer|float
pointRanges() public static method

Get point ranges

public static array pointRanges ( $lat, $lng, $dist, $unit self::KM )
$lat float

Latitude of center point in [deg decimal]

$lng float

Longitude of center point in [deg decimal]

$dist integer|float

The radius of distance between 2 points

$unit string

[optional] Default is km

vincentyDistance() public static method

Calculates the great-circle distance between two points, with the Vincenty formula.

public static float vincentyDistance ( $latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $unit self::KM )
$latitudeFrom float

Latitude of start point in [deg decimal]

$longitudeFrom float

Longitude of start point in [deg decimal]

$latitudeTo float

Latitude of target point in [deg decimal]

$longitudeTo float

Longitude of target point in [deg decimal]

$unit string

[optional] Unit

return float

Distance between points in [m] (same as earthRadius)