User:Suyash.dwivedi/userscripts/WikidataLocationButton

Wiki's Lazy Coders

Wikidata Location Button

WikidataLocationButton is a user script that allows you to quickly insert the

Camera location 00′ 00″ N, 0° 00′ 00″ E Kartographer map based on OpenStreetMap.View all coordinates using: OpenStreetMapinfo

template into a file page by fetching coordinates directly from the file's corresponding Wikidata entity (Structured Data).

Installation

To install this script, add the following code to your common.js page:

 // Wikidata Location Button mw.loader.load('https://commons.wikimedia.org/wiki/User:Suyash.dwivedi/userscripts/WikidataLocationButton.js?action=raw&ctype=text/javascript');

How to use

Navigate to a File: page on Wikimedia Commons.

Locate the button labeled Add

Camera location 00′ 00″ N, 0° 00′ 00″ E Kartographer map based on OpenStreetMap.View all coordinates using: OpenStreetMapinfo

from Wikidata near the top of the page (below the title).

Click the button.

The script will:

Check the Structured Data (Wikidata) of the file for the Coordinates of the point of view (P1259) property.

Fetch the current page wikitext.

Append or update the

Camera location 00′ 00″ N, 0° 00′ 00″ E Kartographer map based on OpenStreetMap.View all coordinates using: OpenStreetMapinfo

template at the end of the content.

Refresh the page once the edit is successful.

Features

Precision Handling: Latitude and longitude are rounded to 7 decimal places for accuracy.

Smart Update: If a

Camera location 00′ 00″ N, 0° 00′ 00″ E Kartographer map based on OpenStreetMap.View all coordinates using: OpenStreetMapinfo

template already exists, the script replaces it to ensure the coordinates remain synchronized with Wikidata.

Validation: Prevents the insertion of invalid or "zero" coordinates (0.0, 0.0).

Automated Summary: Adds a clear edit summary indicating that the location was added via Wikidata.

Created by Suyash Dwivedi | Updated on: 8 January 2026
Category:User scripts#WikidataLocationButton Category:Wikimedia Commons tools#WikidataLocationButton
Category:Pages with coordinates Category:User scripts Category:Wikimedia Commons tools