עזרה של Kartographer

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Help:Extension:Kartographer and the translation is 24% complete.

Outdated translations are marked like this.
Other languages:
العربية • ‎অসমীয়া • ‎asturianu • ‎Deutsch • ‎English • ‎español • ‎suomi • ‎français • ‎galego • ‎עברית • ‎magyar • ‎Bahasa Indonesia • ‎日本語 • ‎Ripoarisch • ‎македонски • ‎português do Brasil • ‎русский • ‎سنڌي • ‎svenska • ‎Tiếng Việt • ‎中文
PD הערה: כאשר אתם עורכים דף זה, אתם מסכימים לשחרר את תרומתכם תחת רישיון CC0. ראו את דפי העזרה בנושא נחלת הכלל למידע נוסף.
PD

הדף הזה מתעד איך להשתמש בהרחבה Kartographer ובתגים <mapframe> ו־<maplink> שהיא מספקת.

תחילת העבודה

Downtown San Francisco

הקוד יכניס מפה הידודית פשוטה (כמו שאתם רואים משמאל), עם האפשרות להגדיל אותה באמצעות לחיצה כפולה או לחיצה על סמל בפינה הימנית.

<mapframe text="Downtown [[wikipedia:San Francisco|San Francisco]]" width=250 height=250 zoom=13 latitude=37.8013 longitude=-122.3988 />

אפשר להשתמש בפרמטר align כדי לשנות את היישור – left (שמאל), right (ימין) או center (מרכז). The attribute zoom allows for zoom levels between 0 and 19. Zero is the furthest out, 19 the furthest in.

שימוש ב־<mapframe>

San Francisco museums

התג <mapframe> חייב להיות ריק או להכיל GeoJSON תקין עם סגנון, כפי שמיוצר על־ידי עורך GeoJSON. ההרחבה Kartographer תומכת בתקן simplestyle עם סמלי Maki (ברישיון קריאייטיב קומונס אפס).

<mapframe text="San Francisco museums" width=350 height=350 zoom=13 latitude=37.8013 longitude=-122.3988>
{
  "type": "Feature",
  "geometry": { "type": "Point", "coordinates": [-122.3988, 37.8013] },
  "properties": {
    "title": "[[wikipedia:Exploratorium|Exploratorium]]",
    "description": "[[File:Giant_Mirror_at_the_Exploratorium.jpeg|200px]]",
    "marker-symbol": "museum",
    "marker-size": "large",
    "marker-color": "0050d0"
  }
}
</mapframe>

Frames

Frameless maps are good for insertion as part of a template, whereas framed maps are good for insertion directly into the page, either by hand or by using the visual editor.

  • To insert a map without a frame, add the "frameless" attribute: <mapframe frameless ...>
  • To add a caption, use the text="..." attribute.

Note: Adding the text attribute automatically enables a frame, even if there is a frameless attribute.

<maplink>

שינוי <mapframe> ל־<maplink> יוצר קישור למפה בגודל מסך מלא: 37°48′37″צפ 122°23′58″מע

<maplink zoom="13" latitude="37.8103" longitude="-122.3995" />

<maplink> מקבל גם את הפרמטר הנוסף "text" כדי לציין את טקסט הקישור במקום נקודות הציון: click me

<maplink text="click me" zoom="13" latitude="37.8103" longitude="-122.3995" />

התג <maplink> יכול להכיל את אותו ה־geojson כמו <mapframe>.

<maplink> ומונים אוטומטיים

Several groups of automatic counters

<maplink> מייצר קישור שמראה מפה בגודל מסך מלא אחרי לחיצה. אפשר להגדיר את טקסט הקישור עם המאפיין text. ללא המאפיין הזה יוצגו הקואורדינטות (דוגמה: 12°18′0″צפ 45°36′0″מז). אם מפה משתמשת ב־GeoJSON, תהיה הגדרה של marker-symbol לערך הקסם ‑number או ‑letter. במקרה הזה כל ‑number יוחלף במונה עולה 1, 2, 3... ו־‑letter – בערכי A...Z.

אם ל־GeoJSON יש יותר ממונה אחד, הערך של הראשון יוצג בתור טקסט הקישור. ישנה אפשרות לעורכים להוסיף סיומת למונים מרובים בדף באותו זמן. בדרך הזאת ל־‑number‑museum יהיה מונה שונה מ־‑number‑bar.

יהיה הגיוני להשתמש בצבע ייחודי לכל קבוצת מנייה. כל הנתונים שנוספו דרך <maplink> יוצגו גם בכל המפות שהוכנסו עם <mapframe> אלא אם משמש המאפיין group.

{{see
| name=Exploratorium | url=http://www.exploratorium.edu/
| lat=37.8013 | long=-122.3988
| content=A great museum
}}

אפשר להרחיב ל־:

<maplink zoom=9 latitude=37.8013 longitude=-122.3988>
{
  "type": "Feature",
  "geometry": { "type": "Point", "coordinates": [-122.3988, 37.8013] },
  "properties": {
    "title": "Exploratorium",
    "marker-color": "228b22",
    "marker-symbol": "-number-see"
  }
}
</maplink>

המאפיינים zoom, latitude, ו־longitude מגדירים את המיקום של המפה הקופצת. יש להשתמש ב־$alt לטקסט הרמז של הקישור. יש להשתמש ב־text לטקסט על הקישור (זה יכול להיות כל קוד ויקי תקין). יש להשתמש ב־group כדי להוסיף את התוכן של התג הזה לקבוצה בעלת השם (ר' להלן).


Markers

Complex map - marker, article link and image

Markers can be added to maps to denote a location. These features are added using the JSON format.

Note: These examples use maplink. The formatting for mapframe is the same, except that latitude=, longitude=, and zoom= must be specified (otherwise the map on the saved page will be centered on northern Africa).

<maplink text="Colorado State Capital with marker icon" latitude="39.73939" longitude="-104.98491" zoom="17">{"type": "Feature", "properties": { "marker-symbol": "", "marker-color": "46ea5f", "marker-size": "medium"}, "geometry": { "type": "Point", "coordinates": [-104.98485267162323, 39.73928364167763] }}</maplink>

Result: Colorado State Capital with marker icon

Markers can also contain information such as images and links to articles.

<maplink text="Colorado State Capital with a town hall marker, article link and image" latitude="39.73939" longitude="-104.98491" zoom="17">
{
      "type": "Feature",
      "properties": { "marker-symbol": "town-hall", "marker-color": "46ea5f", "marker-size": "medium", "title": "[[wikipedia:Colorado_State_Capitol|Colorado State Capital]]", "description": "[[File:Coloradocapitolhill2.JPG|150px]]"},
      "geometry": { "type": "Point", "coordinates": [-104.98485267162323, 39.73928364167763] }
}
</maplink>

Result (interact with marker to see result): Colorado State Capital with a town hall marker, article link and image

Wikidata IDs for OSM data can be used to highlight borders using the geoshape service.

<maplink text="State of Colorado, outlined" zoom=7 > { "type": "ExternalData", "service": "geoshape", "ids": "Q1261" } </maplink>

Result: State of Colorado, outlined

Wikidata IDs can be used to mask the entire map except a specified region.

<maplink text="State of Colorado, highlighted" zoom=7 > { "type": "ExternalData", "service": "geoshape", "ids": "Q1261", "service": "geomask" } </maplink>

Result: State of Colorado, highlighted

Markers can be numbered.

<maplink text="Colorado State Capital with a number marker" latitude="39.73939" longitude="-104.98491" zoom="17">{ "type": "Feature", "properties": {  "marker-color": "228b22", "marker-symbol": "-number"}, "geometry": { "type": "Point", "coordinates": [-104.98485267162323, 39.73928364167763] }}</maplink>

Result: Colorado State Capital with a number marker

Markers can use letters.

<maplink text="Colorado State Capital with a letter marker" latitude="39.73939" longitude="-104.98491" zoom="17">{ "type": "Feature", "properties": {  "marker-color": "508e33", "marker-symbol": "-letter"}, "geometry": { "type": "Point", "coordinates": [-104.98485267162323, 39.73928364167763] }}</maplink>

Result: Colorado State Capital with a letter marker

Add several map markers in different sizes using a feature collection.

<maplink text="Denver Amusements" latitude="39.74956567318853" longitude="-105.01247406005858" zoom="14"> {"type": "FeatureCollection", "features":  [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [-105.00768899917603, 39.74859230437501] }, "properties": { "title": "[[wikipedia:Pepsi_Center|Pepsi Center]]", "marker-color": "420617", "marker-symbol": "-letter-see", "marker-size":"small"} }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-105.01238822937012, 39.7526011757416] }, "properties": { "title": "[[wikipedia:Downtown_Aquarium%2C_Denver|Downtown Aquarium Denver]]", "marker-color": "508e33", "marker-symbol": "-letter-see","marker-size":"medium", "description": "[[File:Denver-DTA.jpg|150px]]" } }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-105.01247406005858, 39.74956567318853] }, "properties": { "title": "[[wikipedia:Confluence_Park|Confluence Park]]", "marker-color": "0d2751", "marker-symbol": "-letter-see", "marker-size":"large" } }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-105.01646518707275, 39.74656303364532] }, "properties": { "title": "South Platte Bike Trail", "marker-color": "61b9e2", "marker-symbol": "-number-see", "marker-size":"medium" } },]}</maplink>

Result: Denver Amusements

Add groups of different colored map markers and different counters.

<maplink text="Add groups of different colored markers and different counters" width="350" height="350" zoom="13" longitude="-122.39902496337889" latitude="37.80151060070086"> {
"type": "FeatureCollection", "features":  [
    { "type": "Feature",
      "properties": {
        "marker-symbol": "-number",
        "marker-color": "302060" },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.41816520690917, 37.79097260220947 ] }},
    { "type": "Feature",
      "properties": {
        "marker-symbol": "-number",
        "marker-color": "302060"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.40786552429199, 37.799654055191525 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-number",
        "marker-color": "302060"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.40185737609865, 37.796262984039544 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-number",
        "marker-color": "302060"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.38743782043457, 37.80535070427755 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-number",
        "marker-color": "302060"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.38005638122557, 37.795449103799726 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-letter",
        "marker-color": "208020"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.40941047668457, 37.81850557172186 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-letter",
        "marker-color": "208020"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.40357398986815, 37.81280993744834 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-letter",
        "marker-color": "208020"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.39842414855956, 37.8071138637568 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-number-bar",
        "marker-color": "f01080"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.41181373596191, 37.78595317184089 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-number-bar",
        "marker-color": "f01080"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.39542007446289, 37.787674400057654 ] }},
    {
      "type": "Feature",
      "properties": {
        "marker-symbol": "-number-bar",
        "marker-color": "f01080"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122.38649368286131, 37.78401144262929 ] }}
  ] }</maplink>

Result: Add groups of different colored markers and different counters

  • Map markers can use any color that has a RBG value (a quick internet search of "rgb color picker" will show several options).
  • Markers can be one of three different sizes: small, medium or large.
  • GeoJSON that is created elsewhere can be copied (in accordance with licensing and copyright restrictions) and then pasted into maplink (for example)
  • If you are creating maps on Wikivoyage, it might be a good idea to use Groups (see below).
  • If you want to learn more about adding external data to your map, see the External data section.

קבוצות

The groups feature is only available in Wikivoyage (per VisualEditor team request)

לשימוש במיזם ויקימסע יש צורך להגדיר מפה שהנתונים שלה מוגדרים במקום אחר בדף. למשל, ייתכן שיש נקודות עניין (POI) מרובות שמוגדרות עם תגי <maplink>, ומפה משותפת אחת בצד הדף שמציגה את כולן.

רעיון הקיבוץ (grouping) מאפשר לעורכים לשתף נתונים בין תגי <mapframe> ו־<maplink> מרובים.

אלא אם נאמר אחרת, הנתונים בתג <mapframe> או <maplink> מוצגים רק עבור תג אחד, ולא יוצגו בשום מקום אחר.

אם <mapframe> או <maplink> מגדירים את המאפיין group="...", הנתונים בתוך התגים האלה יוכנסו לקבוצה בעלת שם, יחד עם כל הנתונים באותה הקבוצה. כתוצאה מזה, כל התגים באוה הקבוצה תציג את אותם נתוני המפה, וכל תג יוכל להוסיף נתונים מצטברים לקבוצה.

תג יכול להציג גם קבוצות אחרות, אם הוא שייך לקבוצה ואם לא, באמצעות ציון show="...". אפשר לציין שמות קבוצה מרובים מופרדים בפסיק. שם הקבוצה יכול להכיל רק אותיות קטנות באנגלית. המטריצה הזאת מציגה אילו נתונים יוצגו לכל תג.

 1 <maplink>                               -- shows 1
 2 <maplink group='food'>                  -- shows   2   4       8   10
 3 <maplink group='bar'  show='bar'>       -- shows     3           9
 4 <maplink group='food' show='bar'>       -- shows   2 3 4       8 9 10
 5 <maplink              show='bar'>       -- shows     3   5       9
 6 <maplink              show='food,bar'>  -- shows   2 3 4   6   8 9 10
 7 <mapframe>                              -- shows             7
 8 <mapframe group='food'>                 -- shows   2   4       8   10
 9 <mapframe group='bar'  show='bar'>      -- shows     3           9
10 <mapframe group='food' show='bar'>      -- shows   2 3 4       8 9 10
11 <mapframe              show='bar'>      -- shows     3           9    11
12 <mapframe              show='food,bar'> -- shows   2 3 4       8 9 10    12

External data

A geoshape of Alaska

In addition to drawing polygons using GeoJSON, you may also get outlines of the well known geographical objects by their Wikidata ID if they are marked as such in the OpenStreetMap database. For example, the Wikidata item for Alaska is Q797, and we can draw it on a map by using the "external data" reference. More than one ID may be specified separated by a comma. To create a mask over the areas of interest, use the "geoshape" service. To invert this and create a mask over everything else, use the "geomask" service.

Wikidata IDs are relatively new to the OSM community. There are only about 40,000 polygons with IDs. To add more, visit https://www.openstreetmap.org/ and add wikidata tag with the Q value (see Key:wikidata on OSM wiki for an easier way to do it). The data should become available to Kartographer within 2 days. For detailed instructions, see Help:Extension:Kartographer/OSMHelp:Extension:Kartographer/OSM.
<mapframe text="A geoshape of Alaska" width=300 height=300 zoom=3 latitude=64.01 longitude=-152.58>
{
  "type": "ExternalData",
  "service": "geoshape",
  "ids": "Q797"
}
</mapframe>


GeoShapes via Wikidata Query

Governors of US states with their party affiliation

While this helps with the simple use cases when the Wikidata ID is well known, sometimes you may want to get a list of IDs as a result of a Wikidata query. A SPARQL query gets a list of all US states in the ID column of the result, and geoshapes service adds the geometrical outlines for each state. All other columns in the SPARQL query result become values in the "properties" object. The "fill" column changes the color of the state. The "title" column shows state governor's name, and "description" has wiki markup to show the state name and the governor's picture. To edit this query, copy the query parameter after the "#" symbol at https://query.wikidata.org/#...:

<mapframe latitude="52" longitude="-110" zoom="3" width="500" height="500" text="Governors of US states with their party affiliation">
{
  "type": "ExternalData",
  "service": "geoshape",
  "query": "
SELECT ?id ?head
  (SAMPLE(?img) as ?img) 
  (min(?partyId) as ?party) 
  (if(?party = '0', '#800000', if(?party = '1', '#000080', '#008000')) as ?fill)
  (concat('[[wikipedia:', substr(str(?link),31,500),  '{{!}}', ?headLabel, ']]') as ?title)
  (concat(?stateLabel, '\\n', '[[File:', substr(str(?img), 52, 500), '{{!}}200px]]') as ?description)
WHERE {  
  ?id wdt:P31 wd:Q35657 .
  ?id wdt:P6 ?head .
  ?head wdt:P102 ?party .
  BIND(if(?party = wd:Q29468, '0', if(?party = wd:Q29552, '1', '2')) as ?partyId) 
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language 'en' .
    ?head rdfs:label ?headLabel .
    ?id rdfs:label ?stateLabel .
  }
  OPTIONAL {
    ?head wdt:P18 ?img .
  }
  ?link schema:about ?head .
  ?link schema:isPartOf <https://en.wikipedia.org/> .
} GROUP BY ?id ?head ?headLabel ?link ?stateLabel
"}
</mapframe>

Map data from Commons

Further information: Help:Map DataHelp:Map Data

Map data stored on Commons can be drawn on the map. For example, c:Data:Neighbourhoods/New York City.map:

<mapframe width=300 height=400 zoom=11 latitude=40.7920 longitude=-73.9751>
{
  "type": "ExternalData",
  "service": "page",
  "title": "Neighbourhoods/New York City.map"
}
</mapframe>


Combining multiple data types

Caderousse city wall

You can combine ExternalData, Feature, and FeatureCollection together in the same <mapframe> or <maplink> element:

<mapframe text="Caderousse city wall" width="300" height="300" zoom="15" latitude="44.10200" longitude="4.75600">
[
  {
    "type": "ExternalData",
    "service": "geoshape",
    "ids": "Q13518258",
    "properties": {
      "stroke": "#ffb100",
      "stroke-width": 6,
    }
  },
  {
    "type": "Feature",
    "geometry": { "type": "Point", "coordinates": [4.75566, 44.104498] },
    "properties": {
      "title": "Porte de Castellan"
    }
  },
  {
    "type": "Feature",
    "geometry": { "type": "Point", "coordinates": [4.75829, 44.10258] },
    "properties": {
      "title": "Porte Léon Roche"
    }
  }
]
</mapframe>

Map data from Commons can be combined with other types of data:

<mapframe width="300" height="300" zoom="12" latitude="40.782222" longitude="-73.965278">
[
  {
    "type": "ExternalData",
    "service": "page",
    "title": "Neighbourhoods/New York City.map"
  },
  {
    "type": "ExternalData",
    "service": "geoshape",
    "ids": "Q160409",
    "properties": {
      "fill": "#07c63e", "title": "Central Park"
    }
  },
  {
    "type": "Feature",
    "properties": {"title": "Roosevelt Island", "marker-color": "f01080"},
    "geometry": {
      "type": "Point",
      "coordinates": [
        -73.94511222839355,
        40.76734665426719
      ]
    }
  }
]
</mapframe>


Styling

Styling Wikidata ID elements

Interstate Highway I-696

For external data, you can also add styles and titles, using the properties keyword:

<mapframe text="Interstate Highway I-696" width="300" height="300" latitude="42.4883" longitude="-83.2297" zoom="9">
{
  "type": "ExternalData",
  "service": "geoline",
  "ids": "Q2108",
  "properties": {
    "title": "Highway I-696",
    "description": "[[File:I696-1988.JPG|200px]]",
    "stroke": "#ffb100",
    "stroke-width": 8
  }
}
</mapframe>

The main style keys are: "stroke" (color), "stroke-width", "stroke-opacity", "fill" (color), "fill-opacity".


Overlapping elements

Map elements that overlap are drawn in the order in which they are written in the code. For instance, if a map includes two lines that overlap, the line that is defined first will appear beneath the line that is defined second. The following examples show how this can affect the appearance of the map:

The code for the map above includes three elements, all of which use GeoJSON's "feature" functionality. The first feature is a "Polygon" - the red rectangle. This is followed by two "LineString" features. The yellow line is defined first, so it appears beneath the black line. Note that the hierarchy used to draw elements applies regardless of whether the data is raw GeoJSON or comes from a Wikidata ID or Commons data page.

The map below changes the order from that of the first example: the black line is defined first and is thus moved to the bottom of the stack:

Rendering options

The following table shows how a <mapframe> map can be formatted for display on a wiki page. The table contains two columns: the first shows an interactive map via the <mapframe> tag, and the second showing the rendering of an example image with the same options.

Options Rendering a <mapframe> Rendering an image
  • Format: frame
  • Alignment: undefined
... text text text
text text text ...
... text text text
Example en.svg
text text text ...
  • Format: frame
  • Alignment: none
Not supported, see task T157502. ... text text text
Example en.svg
text text text ...
  • Format: frame
  • Alignment: left
... text text text
text text text ...
... text text text
Example en.svg
text text text ...
  • Format: frame
  • Alignment: center
... text text text
text text text ...
... text text text
Example en.svg
text text text ...
  • Format: frame
  • Alignment: right
... text text text
text text text ...
... text text text
Example en.svg
text text text ...
  • Format: frameless
  • Alignment: undefined
... text text text text text text ...

Inconsistent, see task T157640.
... text text text Example en.svg text text text ...
  • Format: frameless
  • Alignment: none
Not supported, see task T157502. ... text text text
Example en.svg
text text text ...
  • Format: frameless
  • Alignment: left
... text text text text text text ... ... text text text
Example en.svg
text text text ...
  • Format: frameless
  • Alignment: center
... text text text text text text ... ... text text text
Example en.svg
text text text ...
  • Format: frameless
  • Alignment: right
... text text text text text text ... ... text text text
Example en.svg
text text text ...

Map languages

Map labels will try to use the language of the wiki where the embedded map is displayed. If that language is not available, then the map will use fallback language as described.

  1. Look for value in the requested language
  2. Look for value in a language (or languages) that are specifically defined as fallback languages
  3. Look for a transliterated value
  4. Look for label in the local language
  5. If no value is found, display no label.

You can specify the language to use for labels by adding the lang= followed by the desired language code. e.g. lang="ja" to display labels in Japanese (if available).

<maplink text="Brussels, Belgium" width="250" height="250" zoom=13 latitude=50.85 longitude=4.35 lang="ja"/>

Result: Brussels, Belgium

If you wish to use the language local to an area you can use lang=local. This shows map labels in the languages of the area mapped (essentially opting out of internationalization). This post gives more guidance about when, and why, you might wish to user lang="local"—and generally explains how OpenStreetMap multilingual data works.

Without the lang= attribute, maps will display in the language of the wiki in which they appear.

Map language fallbacks

Initially these fallbacks follow those found in MediaWiki. The language fallbacks for Maps are stored in fallbacks.json and can be made different than the Mediawiki settings. Individual Wikimedia projects can request a change to this fallback process in Phabricator. More Technical information can be found in T192701.

Maps use map data, including map label data for all languages, from the open-source mapping project OpenStreetMap. If the map you want to display doesn’t offer labels in the desired language, you can add labels in that language by adding them to OpenStreetMap. To get you started, there is an OpenStreetMap Beginners’ Guide, and guidance about naming conventions.

A community can decide to change its language fallbacks

Read all about changing your language's fallbacks on the Map Improvements project page.

See also