Quantcast
Channel: Uncategorized - Wikimedia Developer Support
Viewing all articles
Browse latest Browse all 21

Add map coordinate in Wikidata

$
0
0

@Jayprakash12345 wrote:

Hello, I am working on a user script that will add the coordinates. For that, I using following API

var snakData = '{ "latitude":' + newCoords[0] + ',"longitude":' + newCoords[1] + ',"precision": 0.016666666666667,"globe":"http://www.wikidata.org/entity/Q2"}';

var api = new mw.ForeignApi( 'https://www.wikidata.org/w/api.php' );

api.postWithToken( 'csrf', {
    "action": "wbcreateclaim",
    "entity": item,
    "snaktype": "value",
    "property": "P625",
    "summary": "Add/Modify Geo Coordinate",
    "value": snakData,
    "format": "json"
} ).done( function ( data ) {
    console.log( data ); 
} ).fail( function ( data ) {
    console.log( data );
} );

It adds a statement in item (Expected). But on the second time, It adds a another statement even statement is already there. So will I have to create another function to check P615 is exist or not? or there is any other wikidata API which will create or modify the current map coordinate.

And another thing, What the mean by precision in snakData? I am not able to add coordinate with precision.

Thank your :slight_smile:

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 21

Trending Articles