sceneToScreen(point: PP.Vector3);
point. The point, whose coordinates you need to determine.
The sceneToScreen method returns window coordinates of the point, corresponding to world coordinates.
The method returns a PP.Vector3 value.
To execute the example the HTML page must contain the MapChart component named map and the ). A map with the Sphere topobase must also be loaded (see page with description of the MapChart.AmbientLightValue property ToolBar property named MapType (see Example of Creating the MapChart Component). A map with the Sphere topobase must also be loaded (see page with description of the MapChart.AmbientLightValue property ).
Determine coordinates of the central point in the map layer area with the ID RU, and also its screen coordinates, that correspond to world coordinates:
// Get the map layer area by identifier var shape = map.getShape("RU"); // Get coordinates of the central point of the map layer area var center = shape.getCenter(); console.log("Coordinates of the central point of the RU map layer area: (" + center.getX() + ", " + center.getY() + ")"); // Get screen coordinates of the central point of the area central point corresponding to the world ones var worldCenter = map.sceneToScreenIfVisible(center); if (worldCenter != null) { console.log("Area center is visible. Its screen coordinates are as follows: (" + worldCenter.getX() + ", " + worldCenter.getY() + ")"); } else { // If the point is not visible var worldCenter = map.sceneToScreen(center); console.log("Area center is not visible. Its screen coordinates are as follows: (" + worldCenter.getX() + ", " + worldCenter.getY() + ")"); };
After executing the example the browser console displays coordinates of center for the map layer area with the RU identifier, screen coordinates of this point corresponding to world coordinates, and indication if this point is currently visible:
Coordinates of the RU map layer area center: (0.04692089919735823, 0.08969734328771321)
Area center is not visible. Its screen coordinates are as follows: (733.045080511899, 32.628379434266044)
See also: