Widget:Display map

From Visual Data Wiki
Revision as of 12:26, 6 April 2024 by Uschuetzenmeister (talk | contribs) (Created page with "<noinclude>__NOTOC__ This is the <em>widget: display map</em>. It displays an interactive map on the page where it is called. <br /><br /> Call: <em><nowiki>{{#widget: display map |markerdata=array of JSON objects |height=integer |width = integer}}</nowiki></em><br/><br/> Parameters:<br/> *<em>markerdata</em>: required, a JSON Object that is created through a template (see e.g. <em>template:webmo map main page</em> and below for further info) or directly to the widget l...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is the widget: display map. It displays an interactive map on the page where it is called.

Call: {{#widget: display map |markerdata=array of JSON objects |height=integer |width = integer}}

Parameters:

  • markerdata: required, a JSON Object that is created through a template (see e.g. template:webmo map main page and below for further info) or directly to the widget like: [{marker1 data},{marker2 data},{marker3 data}]
  • height: optional, integer in pixels, e.g.: 500; defaults to 700
  • width: optional, integer in pixels, e.g.: 500; defaults to 100%

By sending different data to the widget you may modify the map that gets displayed. The data comes in the JSON format. If ineterested, please check out the gentle json introduction.

The data set with the parameter markerdata is an array of JSON objects. It works like an array of records. Each record represents a marker and contains data belonging to that marker. The data contained in markerdata could be the coordinates or any HTML content that can be displayed as a popup. Or a date to check against the current date to display expired markers differently.

For example, the following abstract array contains data for three markers:

[{marker1 data},{marker2 data},{marker3 data}]

Let's take the first record {marker1 data} as an exmaple. In its most basic form it needs to look like this:

{"coordinates": "34.32, -32.333"}

This will draw a map and place a blue marker icon at the location. Extending the record like this:

1) {"coordinates": "34.32, -32.333", "popupContent":"Test"}
2) {"coordinates": "34.32, -32.333", "projectEndDate":"2012-07-03"}
3) {"coordinates": "34.32, -32.333", "pathToMarkerIconCurrent":"http://domain.xu/test.jpg", "pathToMarkerIconExpired":"http://domain.xu/test.jpg", }

will

1) add a popup to the marker which displays the content "Test". You can use HTML and add images and tables.
2) evaluate each marker against the current date and display a different marker if projectEndDate < now
3) change the default icons to the ones provided found at the url

Below is an example array which contains all available options. It will put two markers on a map with custom icons. The markers will have different icons depending on whether the dates are in the past or not. The names "coordinates", "projectEndDate", "popupContent", "pathToMarkerIconCurrent", "pathToMarkerIconExpired" are fixed an must not be changed.

[ {"coordinates": "34.32, -32.333", "popupContent":"test", "pathToMarkerIconCurrent":"http://domain.xu/test.jpg", "pathToMarkerIconExpired":"http://domain.xu/test.jpg","projectEndDate":"2018-07-03"},

{"coordinates": "24.32, -31.333", "popupContent":"test2", "pathToMarkerIconCurrent":"http://domain.xu/test.jpg", "pathToMarkerIconExpired":"http://domain.xu/test.jpg","projectEndDate":"2012-07-03"} ]


Created by [idea-sketch.com idea-sketch.com]