Module:Infobox mapframe/sandbox: Difference between revisions

Content deleted Content added
Create sandbox version of Module:Infobox mapframe
 
check for OSM relation id
Line 22:
local coordStatements = mw.wikibase.getBestStatements(item_id, 'P625')
if not coordStatements or #coordStatements == 0 then
return false
end
return true
end
 
function hasWikidataOSMrelation(item_id)
if not(item_id) or not(mw.wikibase.isValidEntityId(item_id)) or not(mw.wikibase.entityExists(item_id)) then
return false
end
local OSMRelationStatements = mw.wikibase.getBestStatements(item_id, 'P402')
if not OSMRelationStatements or #OSMRelationStatements == 0 then
return false
end
Line 45 ⟶ 56:
p._main = function(_config)
local config = setCleanArgs(_config)
local wikidataId = config.id or mw.wikibase.getEntityIdForCurrentPage()
-- Require wikidata item with coords, so something will definetly be displayed
if not wikidataId then
return ''
end
 
-- Require wikidata item with coords, so something will definetly be displayedcentred somewhere
if not hasWikidataCoords(config.id or mw.wikibase.getEntityIdForCurrentPage()) then
return ''
Line 86 ⟶ 102:
 
-- Point
if not hasWikidataOSMrelation(wikidataId) then
args.type3 = "point"
args.type3 = "point"
if config.id then args.id3 = config.id end
if config.marker then args.marker3 = config.marker end
args["marker-color"] = config["marker-color"] or config["marker-colour"] or "#5E74F3"
end
 
local mapframe = mf._main(args)
return mapframe