Markers & Texts
intermediate conceptsWorld Map Globe Ultra Edition · Core Concepts
The globe draws circles, range rings, quads, polygons, lines and texts on the ground. The terrain itself draws them, so they follow the relief and they do not need any object in the scene. Each method returns a PlanetaryMarker that you can change or remove later. The methods have the names of World Map Globe Edition.
Adding Markers
| Method | Description |
|---|---|
AddMarker(PlanetaryMarkerType.Circle, double latitude, double longitude, float kmRadius, float ringWidthStart, float ringWidthEnd, Color color) | A circle with a radius in kilometers. The ring limits go from 0 at the center to 1 at the radius. Pass 0 and 1 for a full circle, or for example 0.8 and 1 for a thick ring. |
AddMarker(PlanetaryMarkerType.Quad, double latitudeTopLeft, double longitudeTopLeft, double latitudeBottomRight, double longitudeBottomRight, Color fillColor, Color borderColor = default, float borderWidth = 0) | A quad between its north west corner and its south east corner. Its north and south edges follow their parallels. |
AddLine(Vector2[] latlon, Color color, float lineWidth) | A line through a list of points, along the shortest way between each two points. |
AddLine(double latitudeStart, double longitudeStart, double latitudeEnd, double longitudeEnd, Color color, float lineWidth) | A line between two places, along the shortest way. |
AddPolygon3D(Vector2[] latlon, Color borderColor, Color fillColor = default) | A polygon with a border of 2 pixels. Change the width with borderWidth of the marker. |
AddText(string text, double latitude, double longitude, Color color, float kmSize, float heading = 90) | A text centered at a place. See Texts on the Ground. |
In the arrays, X is the latitude and Y is the longitude of each point.
Removing Markers
| Method | Description |
|---|---|
ClearMarker(PlanetaryMarker marker) | Removes a marker, a line or a text. |
ClearLineMarker(PlanetaryMarker line) | Removes a line. |
ClearMarkers() | Removes all the markers that are not lines, texts included. |
ClearLineMarkers() | Removes all the lines. |
int MarkerCount | Number of markers, lines and texts that you added. |
Changing a Marker
| Member of PlanetaryMarker | Description |
|---|---|
Color color | Color of the fill of a circle, a quad or a polygon, color of a line, or color of the letters of a text. The alpha is its opacity over the terrain. |
Color borderColor | Color of the border of a circle, a quad or a polygon, or of the outline of a text. |
float borderWidth | Width in pixels of the border, of a line or of the outline of a text, from 0 to 16. With 0 there is no border. |
bool visible | Shows or hides the marker. |
bool isLine, isText | Whether the marker is a line or a text. |
SetCircle(double latitude, double longitude, float kmRadius, float ringWidthStart = 0, float ringWidthEnd = 1) | Moves the marker or makes it a circle. |
SetQuad(double latitudeTopLeft, double longitudeTopLeft, double latitudeBottomRight, double longitudeBottomRight) | Makes the marker a quad. The first corner must be north and west of the second. |
SetPoints(Vector2[] latlon, bool line) | Makes the marker a polygon, or a line through the points. |
SetLine(double latitudeStart, double longitudeStart, double latitudeEnd, double longitudeEnd) | Makes the marker a line between two places. |
SetText(string text, double latitude, double longitude, float kmSize, float heading = 90, float spacing = 0) | Changes the text or moves it. The spacing is added between letters, in parts of the size. |
A change of color, border or visibility is cheap. A change of place or of shape makes the globe read again the markers of the tiles that the marker touches.
Example
using UnityEngine;
using WPM;
public class MarkersSample : MonoBehaviour {
public WorldMapGlobeUltra globe;
PlanetaryMarker zone, ring, route;
void Start () {
// A circle with a radius of 2 km and a transparent fill
zone = globe.AddMarker(PlanetaryMarkerType.Circle, 45.8326, 6.8652, 2, 0, 1, new Color(0.2f, 0.8f, 1, 0.3f));
// A range ring: a circle with no fill and a border
ring = globe.AddMarker(PlanetaryMarkerType.Circle, 45.8326, 6.8652, 10, 0, 1, Color.clear);
ring.borderColor = Color.yellow;
ring.borderWidth = 2;
// A line through three points (X = latitude, Y = longitude)
route = globe.AddLine(new[] { new Vector2(45.92f, 6.87f), new Vector2(45.88f, 6.89f), new Vector2(45.83f, 6.87f) }, Color.white, 3);
}
void OnDisable () {
globe.ClearMarker(zone);
globe.ClearMarker(ring);
globe.ClearMarker(route);
}
}
Texts on the Ground
AddText adds a text centered at a place. The size is the height of the font in kilometers. The heading is the direction in which the text reads, in degrees from the north: 90, the default, reads to the east. Set borderColor and borderWidth of the marker to give the letters an outline.
PlanetaryMarker label = globe.AddText("Base Camp", 27.98, 86.92, Color.white, 0.5f);
label.borderColor = Color.black;
label.borderWidth = 1.5f;
The texts use the Font of the Political Map Settings. Leave it empty to use the font of the asset. The names of countries and provinces are drawn in the same way. See Names of Countries and Provinces.
Notes
- A newer marker is drawn over an older one.
- The width of a border or of a line is in pixels and it is the same at any distance.
- The fill of a marker takes the light of the Sun and the haze of the ground. The borders and the lines are drawn over the haze, as the country borders are, and they are dark at night. The letters also take the light of the Sun.
- A polygon must have its corners within a quarter of a turn of the planet from its center. It has no holes. Where its edges cross, the fill alternates.
- Lines have no dashes and no animation. For a line in the air, for example an arc or a trajectory, use an object with a Planetary Anchor.
- Markers need a device with buffers in the vertex shader. The desktop graphics APIs have them. On other devices, markers are not drawn.
Coming from World Map Globe Edition
- The methods take a latitude and a longitude, not a position on the sphere.
- The type of a marker is
PlanetaryMarkerType, notMARKER_TYPE. - A width is in pixels.
- The methods return a
PlanetaryMarker, not a GameObject.
Suggest an improvement
Help us improve this documentation page.