Markers API
advanced scriptingWorld Map Globe Edition · Scripting Support (C#)
WorldMapGlobe (namespace WPM). Access via WorldMapGlobe.instance.
Lines
Use AddLine() to draw an animated line or arc between two locations. All overloads return the LineMarkerAnimator component attached to the new line. Configure it right after the call: the underlying renderer is created on the next frame, so changes made immediately after AddLine() are picked up.
LineMarkerAnimator AddLine(Vector2 latLonStart, Vector2 latLonEnd, Color color, float arcElevation, float duration, float lineWidth, float fadeOutAfter)Adds an animated line between two lat/lon coordinates. arcElevation is relative to the sphere size (0-1), duration is the drawing speed (0 = instant), fadeOutAfter fades the line out once drawn (0 = stays forever).
LineMarkerAnimator AddLine(Vector3 spherePosStart, Vector3 spherePosEnd, Color color, float arcElevation, float duration, float lineWidth, float fadeOutAfter, bool reuseMaterial = true)Adds an animated line between two sphere positions.
LineMarkerAnimator AddLine(Vector2[] latlon, Color color, float lineWidth)Adds a line along a sequence of map coordinates.
Useful members of LineMarkerAnimator:
bool useTubeRenders the line as a 3D tube (TubeRenderer) instead of a LineRenderer. Set it right after AddLine(); lineWidth controls the tube thickness.
LineRenderer lineRenderer { get; }The underlying LineRenderer component (when useTube is false).
TubeRenderer tubeRenderer { get; }The underlying TubeRenderer component (when useTube is true).
int numPointsNumber of line points (default 256). Increase for smoother arcs, decrease for performance.
float fadeOutDurationDuration of the fade out effect once triggered.
Example: line rendered as a 3D tube
WorldMapGlobe map = WorldMapGlobe.instance;
LineMarkerAnimator lma = map.AddLine(new Vector2(40.4f, -3.7f), new Vector2(51.5f, -0.1f),
Color.yellow, arcElevation: 0.1f, duration: 2f, lineWidth: 0.005f, fadeOutAfter: 0);
lma.useTube = true;
For the OnLineDrawingEnd and OnLineFadeOut events see the Events page.
Polygons
Use AddPolygon3D() to draw a closed outline over the globe, optionally filled. Coordinates are lat/lon pairs; the last point does not need to repeat the first. The border and the fill are separate renderers under the returned GameObject (border at the root, fill as its child; if there is no border the fill is the root). Polygons of the same color share one material, so to recolor a single polygon use renderer.material, and to recolor a group create your own materials and use the material overloads: changing the material color updates every polygon that uses it without rebuilding anything.
GameObject AddPolygon3D(Vector2[] latlon, Color borderColor, Color fillColor = default)Adds a polygon with a border color and an optional fill color (alpha 0 = no fill).
GameObject AddPolygon3D(Vector2[] latlon, Material borderMaterial, Material fillMaterial)Adds a polygon using your own materials (shared, not instantiated). Pass null to omit the border or the fill. For a translucent or fading fill use the "World Political Map/Unlit Province Surface Single Color Alpha" shader, and "World Political Map/Unlit Single Color Frontiers Alpha" for a fading border.
GameObject AddPolygon3D(Vector2[] latlon, IList<Vector2[]> holes, Color borderColor, Color fillColor = default)Same as above with inner rings (holes), for example lakes inside a region. Holes are drawn as part of the border and cut out of the fill. Each hole must lie inside the outline without touching or crossing it or other holes; a hole that shares a vertex with the outline or another hole is skipped with a warning. Available since 20.2.
GameObject AddPolygon3D(Vector2[] latlon, IList<Vector2[]> holes, Material borderMaterial, Material fillMaterial)Holes with your own materials. Available since 20.2.
bool polygonsBatching { get; set; }Draws all polygons through combined meshes, one per material, which is much faster with thousands of polygons. Off by default; enable it after adding the polygons. While enabled, changes to a polygon material, transform or renderer require RefreshPolygons3D(). Polygons sharing a material are drawn as one object in creation order, so translucent polygons are not depth sorted individually.
void RefreshPolygons3D()Rebuilds the polygon batches after manual changes to polygons (only needed when polygonsBatching is enabled).
To draw something inside a hole (an island in a lake) add a second polygon for it: since the lake is cut out of the first fill, the two fills do not overlap, so translucent and animated colors compose correctly. The border mesh of a polygon is a LineStrip; with holes it uses the Lines topology, one closed run per ring.
Example: region with a lake, an island in the lake, and a fill that fades in
WorldMapGlobe map = WorldMapGlobe.instance;
Material border = new Material(Shader.Find("World Political Map/Unlit Single Color Frontiers"));
Material fill = new Material(Shader.Find("World Political Map/Unlit Province Surface Single Color Alpha"));
border.color = Color.white;
fill.color = new Color(1f, 0.5f, 0f, 0f);
Vector2[] region = ...; // exterior ring (GeoJSON coordinates[0])
Vector2[] lake = ...; // inner ring (GeoJSON coordinates[1])
Vector2[] island = ...; // a separate polygon inside the lake
map.AddPolygon3D(region, new[] { lake }, border, fill);
map.AddPolygon3D(island, border, fill);
map.polygonsBatching = true;
// later, every polygon fades in at once
fill.color = new Color(1f, 0.5f, 0f, Mathf.Clamp01(t));
Mount Points
Mount points are pre-defined points of interest stored in geodata files. Each mount point has a name, type, location, country/province association, and custom attributes.
List<MountPoint> mountPoints { get; set; }List of all mount points.
string mountPointsAttributeFile { get; set; }Filename for mount point attributes data.
string[] GetMountPointNames()Returns all mount point names.
string[] GetMountPointNames(int countryIndex)Returns mount point names within a country.
string[] GetMountPointNames(int countryIndex, int provinceIndex)Returns mount point names within a province.
int GetMountPointIndex(int countryIndex, string mountPointName)Returns mount point index by name within a country.
bool GetMountPointIndex(Ray ray, out int mountPointIndex, int countryIndex = -1)Gets the mount point hit by a ray.
List<MountPoint> GetVisibleMountPoints()Returns mount points visible on screen.
void ToggleMountPointHighlight(int mountPointIndex, Color color, bool highlighted)Highlights or un-highlights a mount point.
void HideMountPointHighlights()Removes all mount point highlights.
void MountPointsDeleteFromSameContinent(string continentName)Deletes all mount points in a continent.
Cursor & Grid Lines
bool showCursor { get; set; }Show the crosshair cursor on the globe.
CURSOR_STYLE cursorStyle { get; set; }Cursor rendering style (legacy or lat/lon).
Color cursorColor { get; set; }Cursor line color.
bool cursorFollowMouse { get; set; }Cursor follows mouse position on the globe.
Vector3 cursorLocation { get; set; }Get or set the cursor position on the globe (sphere coordinates).
bool cursorAlwaysVisible { get; set; }Keep cursor visible even when the mouse is not over the globe.
bool showLatitudeLines { get; set; }Show latitude grid lines.
bool showLongitudeLines { get; set; }Show longitude grid lines.
bool showTropicLines { get; set; }Show tropic lines (Cancer, Capricorn, etc.).
Suggest an improvement
Help us improve this documentation page.