Jump to content

ICT:Cargo Geo Coordinnates: Difference between revisions

From Costa Sano MediaWiki
Created page with "== Handling Geographical Coordinates in Cargo == Geographical data is stored using the '''Coordinates''' field type. This allows for both precise database storage and interactive map displays using Page Forms and Cargo. === 1. Define the Cargo Table === In your table declaration, use the `Coordinates` field type. <pre> {{#cargo_declare:_table=Places |Name=String |Location=Coordinates }} </pre> === 2. Create the Input Form..."
 
No edit summary
Line 48: Line 48:
* '''Precision''': Ensure you use a period (`.`) for decimals and a comma (`,`) to separate the two values.
* '''Precision''': Ensure you use a period (`.`) for decimals and a comma (`,`) to separate the two values.
* '''Services''': While `leaflet` is recommended for its ease of use, you can also use `googlemaps` or `openlayers` if they are configured on your wiki.
* '''Services''': While `leaflet` is recommended for its ease of use, you can also use `googlemaps` or `openlayers` if they are configured on your wiki.
== Choosing a Map Service for Forms ==
To display a map in a form for coordinate input, use the `input type` parameter.
=== Option A: Leaflet (Recommended) ===
Uses OpenStreetMap. No API key required.
<pre>
{{{field|Location|input type=leaflet}}}
</pre>
=== Option B: OpenLayers (Default) ===
Solid open-source alternative.
<pre>
{{{field|Location|input type=openlayers}}}
</pre>
=== Option C: Google Maps ===
Requires a Google Maps API Key to be configured in your wiki's LocalSettings.php.
<pre>
{{{field|Location|input type=googlemaps}}}
</pre>
=== Common Parameters ===
You can customize the map's appearance in the form using these parameters:
* `height`: Height in pixels (e.g., `300`).
* `width`: Width in pixels (e.g., `500`).
* `starting bounds`: Initial map area if no coordinate is set yet (e.g., `-20,-15;50,55`).

Revision as of 10:08, 12 February 2026

Handling Geographical Coordinates in Cargo

Geographical data is stored using the Coordinates field type. This allows for both precise database storage and interactive map displays using Page Forms and Cargo.

1. Define the Cargo Table

In your table declaration, use the `Coordinates` field type.

{{#cargo_declare:_table=Places
|Name=String
|Location=Coordinates
}}

2. Create the Input Form

Use the `leaflet` input type (part of Extension:Page Forms) to provide an interactive map where users can click to set coordinates.

{{{field|Location|input type=leaflet|height=300|width=500}}}

3. Displaying Maps

Display a map for a single location

Use the `#cargo_display_map` function on the page itself to show where the specific place is located.

{{#cargo_display_map:
|point={{{Location|}}}
|service=leaflet
|zoom=14
|height=400
}}

Display all places on a master map

To show all entries from your `Places` table on one map, use a `#cargo_query` with a map format.

{{#cargo_query:
|tables=Places
|fields=_pageName=Page, Name, Location
|format=leaflet
|height=500
}}

Technical Note: Coordinate Format

  • Storage: Cargo stores coordinates as "Latitude, Longitude" in decimal degrees (e.g., `51.2194, 2.8972`).
  • Precision: Ensure you use a period (`.`) for decimals and a comma (`,`) to separate the two values.
  • Services: While `leaflet` is recommended for its ease of use, you can also use `googlemaps` or `openlayers` if they are configured on your wiki.


Choosing a Map Service for Forms

To display a map in a form for coordinate input, use the `input type` parameter.

Option A: Leaflet (Recommended)

Uses OpenStreetMap. No API key required.

{{{field|Location|input type=leaflet}}}

Option B: OpenLayers (Default)

Solid open-source alternative.

{{{field|Location|input type=openlayers}}}

Option C: Google Maps

Requires a Google Maps API Key to be configured in your wiki's LocalSettings.php.

{{{field|Location|input type=googlemaps}}}

Common Parameters

You can customize the map's appearance in the form using these parameters:

  • `height`: Height in pixels (e.g., `300`).
  • `width`: Width in pixels (e.g., `500`).
  • `starting bounds`: Initial map area if no coordinate is set yet (e.g., `-20,-15;50,55`).