Maps API for JavaScript Developer's Guide

H.geo.PixelProjection

Class Summary

PixelProjection transforms pixel world coordinates at a certain scale (zoom level) to geographical coordinates and vice versa. By default, it uses the Mercator projection to transform geographic points into the 2d plane map points, which are adjusted to the current scale.

[ For full details, see the Class Details ]

Property Summary

Table 1. Properties
Properties

projection : {H.geo.IProjection}

This property indicates the geographical projection that underlies the given PixelProjection.

x : {number}

This property holds the x-offset in the projection relative to the top-left corner of the screen.

y : {number}

This property holds the y-offset in the projection relative to the top-left corner of the screen.

w : {number}

This property holds a value indicating the width of the world in pixels.

h : {number}

This property holds a value indicating the height of the world in pixels.

Method Summary

Table 2. Methods
Methods

rescale (zoom)

This method updates the scale exponent for the pixel projection.

getZoomScale () : {number}

This method retrieves the current zoom scale factor previously set by a call to H.geo.PixelProjection#rescale.

geoToPixel (geoPoint, opt_out) : {H.math.IPoint}

This method translates a point defines in terms of its geographic coordinates to pixel coordinates at the specified zoom level.

pixelToGeo (point, opt_out) : {H.geo.IPoint}

This method translates a point defined in terms of its pixel coordinates to a location defined in geographic coordinates.

xyToGeo (x, y, opt_out) : {H.geo.Point}

This method translates the x and y coordinates of a pixel to a geographic point.

latLngToPixel (latitude, longitude, opt_out) : {H.math.Point}

This method translates geographical coordinates (latitude, longitude) supplied by the caller into a point defined in terms of pixel coordinates. This method accepts longitudes outside of the normal longitude range.

pointToPixel (point) : {H.math.Point}

This method method translates a map point to world pixel coordinates relative to current projection offset.

Class Description

PixelProjection transforms pixel world coordinates at a certain scale (zoom level) to geographical coordinates and vice versa. By default, it uses the Mercator projection to transform geographic points into the 2d plane map points, which are adjusted to the current scale.

Constructor Details

H.geo.PixelProjection(opt_projection, opt_sizeAtLevelZero)

Parameters:
 
opt_projection:
{H.geo.IProjection=} [optional]
 
An object representing the projection to use, the default is spherical Mercator H.geo.mercator
opt_sizeAtLevelZero:
{number=} [optional]
 
A value indicating the size of a tile representation of the world in pixels at zoom level 0, the default is 256

Property Details

projection: {H.geo.IProjection}

This property indicates the geographical projection that underlies the given PixelProjection.

x: {number}

This property holds the x-offset in the projection relative to the top-left corner of the screen.

y: {number}

This property holds the y-offset in the projection relative to the top-left corner of the screen.

w: {number}

This property holds a value indicating the width of the world in pixels.

h: {number}

This property holds a value indicating the height of the world in pixels.

Method Details

rescale (zoom)

This method updates the scale exponent for the pixel projection.

Parameters:
 
zoom:
{number}
 
A value indicating the zoom level

getZoomScale () : {number}

This method retrieves the current zoom scale factor previously set by a call to H.geo.PixelProjection#rescale.

Returns:
 
{number}
A value indicating the zoom scale factor

geoToPixel (geoPoint, opt_out) : {H.math.IPoint}

This method translates a point defines in terms of its geographic coordinates to pixel coordinates at the specified zoom level.

Parameters:
 
geoPoint:
{H.geo.IPoint}
 
An object containing the geographic coordinates
opt_out:
{H.math.IPoint=} [optional]
 
An optional point to store the result
Returns:
 
{H.math.IPoint}
An object representing the results of the the conversion to pixel coordinates

pixelToGeo (point, opt_out) : {H.geo.IPoint}

This method translates a point defined in terms of its pixel coordinates to a location defined in geographic coordinates.

Parameters:
 
point:
{H.math.IPoint}
 
An object defining a location on the screen in terms of pixel coordinates
opt_out:
{H.geo.IPoint=} [optional]
 
An optional point to store the result
Returns:
 
{H.geo.IPoint}
An object representing the results of conversion to a geographic location

xyToGeo (x, y, opt_out) : {H.geo.Point}

This method translates the x and y coordinates of a pixel to a geographic point.

Parameters:
 
x:
{number}
 
A value indicating the pixel x-coordinate
y:
{number}
 
A value indicating the pixel y-coordinate
opt_out:
{H.geo.Point=} [optional]
 
An optional point to store the result
Returns:
 
{H.geo.Point}
An object representing the results of the conversion to a geographic location

latLngToPixel (latitude, longitude, opt_out) : {H.math.Point}

This method translates geographical coordinates (latitude, longitude) supplied by the caller into a point defined in terms of pixel coordinates. This method accepts longitudes outside of the normal longitude range.

Parameters:
 
latitude:
{number}
 
The latitude to translate
longitude:
{number}
 
The longitude to translate
opt_out:
{H.math.IPoint=} [optional]
 
An optional point to store the result
Returns:
 
{H.math.Point}
The results of the conversion as a point object containing x and y coordinates (in pixels)

pointToPixel (point) : {H.math.Point}

This method method translates a map point to world pixel coordinates relative to current projection offset.

Parameters:
 
point:
{H.math.IPoint}
 
An object representing the map point to convert
Returns:
 
{H.math.Point}
The result of the conversion as an object containing pixel coordinate