MapTopobaseMeta.Geo

Syntax

Geo: Array;

Description

The Geo property determines an array of objects that bind geographic coordinates to topobase coordinates.

Comments

Property value is set from JSON and returned by the getGeo method. Property value cannot be set with the setGeo method.

The property contains an array of PP.MapGeoItem type objects.

Example

To execute this example, the page must contain the MapChart component named map (see Map Layout on HTML Page). Find out geographic coordinates of the central point in the map layer area with the RU-PER identifier, using available geographic coordinates of the centers of RU-MOW and RU-SPE areas and topobase coordinates of the three regions:

/* Create an object for mapping geographic coordinates 
of the RU-MOW region center with the topobase coordinates */
var mowRect = map.getShape("RU-MOW").getBoundsRect();
var geoItem1 = new PP.MapGeoItem({
    Latitude: 55.751667, // Latitude
    Longitude: 37.617778, // Longitude
    X: mowRect.getLeft() + mowRect.getWidth() / 2, // Topobase X coordinate
    Y: mowRect.getTop() + mowRect.getHeight() / 2, // Topobase Y coordinate
    Id: "RU-MOW"
});
// Create an object of map topobase metadata
var meta = new PP.MapTopobaseMeta({
    // Array of objects of geographic coordinates mapping with topobase coordinates
    Geo: [geoItem1]
});
/* Create and set the second object for mapping geographic 
coordinates of the region with the ID RU-SPE with topobase coordinates */
var speRect = map.getShape("RU-SPE").getBoundsRect();
var geoItem2 = new PP.MapGeoItem({
    Latitude: 59.95, // Latitude
    Longitude: 30.316667, // Longitude
    X: speRect.getLeft() + speRect.getWidth() / 2, // Topobase X coordinate
    Y: speRect.getTop() + speRect.getHeight() / 2, // Topobase Y coordinate
    Id: "RU-SPE"
});
meta.setGeoItem(geoItem2);
// Determine center coordinates for the region with the ID RU-PER
var perRect = map.getShape("RU-PER").getBoundsRect();
var center = new PP.Point({
    X: perRect.getLeft() + perRect.getWidth() / 2,
    Y: perRect.getTop() + perRect.getHeight() / 2,
});
// Determine coefficients of mapping geographic coordinates with topobase coordinates
var yCoef = Math.abs((geoItem2.getLatitude() - geoItem1.getLatitude()) / (geoItem2.getY() - geoItem1.getY()));
var xCoef = Math.abs((geoItem2.getLongitude() - geoItem1.getLongitude()) / (geoItem2.getX() - geoItem1.getX()));
// Get geographic coordinates of the region with the ID RU-PER
var perX = Math.abs(center.getX() - geoItem1.getX()) * xCoef + geoItem1.getLongitude();
var perY = Math.abs(center.getY() - geoItem1.getY()) * yCoef + geoItem1.getLatitude();
console.log("Latitude: " + perY + ", longitude: " + perX);

After executing the example the browser console displays geographic coordinates of the central point in the map layer area with the RU-PER identifier:

Latitude: 59.18602187765048, longitude: 56.32188852435074

See also:

MapTopobaseMeta