leafletcoordinatesmediawikisemantic-mediawiki

Passing coordinates stored in Semantic MediaWiki subobject to Leaflet map


I'd like to pass multiple sets of coordinates from different subobject fields into maps. I have tried storing the coordinates in separate property values and calling them like so:

<div class="LeafletPageMap">{{#ask:[[{{PAGENAME}}]] 
|?Has categorya coordinates
|?Has categoryb coordinates}}</div>

Which works fine, but I'd like to take advantage of the subobjects' ability to hold larger sets of relations-- especially for calls on other pages. I'd like to get a something with the following to work:

{{#subobject:
|locationtidbit= an unexpected tidbit to consider|+sep=;
|locationdescription=Another spot to consider|+sep=;
|locationcoordinates= -45.67805, -38.9820|+sep=;
|locationnotes=a baby subsidiary co.|+sep=;
|@category=geo, location
}}
{{#subobject:
|locationdescription=lorem blah ipsum blah|+sep=;
|locationcoordinates= -74.67805, -103.9820|+sep=;
|locationnotes=afdsdsddfo|+sep=;
|@category=geo, location
}}
{{#subobject:
|locationdescription=less important description|+sep=;
|locationcoordinates= -75.647805, -74.9820|+sep=;
|locationnotes=|+sep=;
|@category=geo, location
}}
{{#subobject:
|locationtidbit= an predictable tidbit to consider|+sep=;
|locationdescription=very important location description |+sep=;
|locationcoordinates= -35.67805, -65.9820|+sep=;
|locationnotes=a bakjh sdkjh sdkjh sd co.|+sep=;
|@category=geo, location
}}

and then call with:

{{#display_map: {{#ask: [[-Has subobject::{{PAGENAME}}]][[Category:geo, location]] 
 |?locationcoordinates #
 |mainlabel=-
 |headers=hide
 |format=plainlist
 |sep=&thinsp;;&thinsp;
}}}}

I have been able to get both the first and last set of coordinates to show respectively, but never the whole group. The above code plots the last set, and if I rename the subobjects to

{{#subobject:1... {{#subobject:2... {{#subobject:3... {{#subobject:4...

for example, the first coordinate will be plotted. Really want to get the whole group and to incorporate subobject groups yet to be realized!

Any advice is much appreciated!


Solution

  • Replace your ask query with:

    {{#ask: [[-Has subobject::{{FULLPAGENAME}}]][[Category:geo, location]] 
     |?locationcoordinates #
     |mainlabel=-
     |headers=hide
     |format=plainlist
     |sep=;
    }}
    
    1. {{PAGENAME}} will not work correctly outside of the main namespace.
    2. Coordinates for {{#displaymap:}} should be separated with ;, no fancy thin spaces.

    Also consider not querying the page itself but passing the coordinates from template or module parametres directly.