Pumpún Dixital. Marqués de Valadares, 14, 5º Ofic 10. APP DEV. Desenvolvemos aplicacións para o ollo e o oído I+D+i PLUS.

Plugin Jsonp Gis

This is a plugin we initially developed for building soundmap mashups.
Its name is Jsonp Gis Plugin and so far it is done for the CMS SPIP. In the future there will be also a WordPress version.

You can download it from SPIP-Zone server:
Jsonp-gis SPIP plugin

The plugin is just two jsonp files that work as an API. It allows people to get the geolocated content from a SPIP site and show it in a different server.


The first file is jsonpgis_all.html and it is loaded as follows:

It lists all geolocated articles. The tags that are included in the json are:

  • latitude
  • longitude
  • id

The reason why it has so few tags is because we want to load a high number of articles at once, and we want to make it fast. So we only put the information necessary for locating a marker in a map, which is latitude and longitude. We also put the id of the article because we could need it if we want to get more information about the article, using the other file of the plugin: jsonpgis_one.html

We can add several parametres ir order to get the results we want to achieve:

It returns articles from a given “rubrique”
We should always pass at least one rubrique as a parameter. If we don’t do so, we get 0 results.
example: http://urlofmywebsite/spip.php?page=jsonpgis_all&id_rubrique=1

It returns jsonp instead of json
example: http://urlofmywebsite/spip.php?page=jsonpgis_all&id_rubrique=1&callback=?
This is how json looks like:

[{"lat": "43.1791","lon": "-7.45435","id":"1891"},{"lat": "43.3115","lon": "-8.54908","id":"1889"}]

And this is how jsonp looks like if we pass “?” as the callback parameter:

?([{"lat": "43.1791","lon": "-7.45435","id":"1891"},{"lat": "43.3115","lon": "-8.54908","id":"1889"}])

it returns articles from a given editor-user
example: http://urlofmywebsite/spip.php?page=jsonpgis_all&id_rubrique=1&id_auteur=1

it returns articles from a given search request
example: http://urlofmywebsite/spip.php?page=jsonpgis_all&id_rubrique=1&recherche=water

it returns articles from a given tag
example: http://urlofmywebsite/spip.php?page=jsonpgis_all&id_rubrique=1&id_mot=1

it limits the number of articles the query returns. For example, if we put limit=10, we only get 10 articles
example: http://urlofmywebsite/spip.php?page=jsonpgis_all&id_rubrique=1&limit=10

All parameters can be combined in order to get different results.
For example, with the following query we get a jsonp with the last 20 articles from rubrique=1, autor=3 that include the word “water”:

Here is an example of how this jsonp looks like:

		"lat": "43.1791",
		"lon": "-7.45435",
		"lat": "43.3115",
		"lon": "-8.54908",
		"lat": "43.3112",
		"lon": "-8.55329",


The second file is jsonpgis_one.html and it is loaded as follows:

It lists all information related to an article. The tags that are included in the json are:

  • title: Title of the article
  • description: Description of the article
  • date: Date when the article was published in standar format
  • permalink: The permalink to the article
  • url_sound: The url of the sound attached to the article. It only lists the last sound attached
  • url_image: The url of the image attached to the article. It only lists the last image attached, which is 400px width and has proportional height.
  • lat: latitude
  • lon: longitude
  • user: name of the user who published the article
  • id: id of the article

It is possible to pass two parameters: id_article and callback:

it is mandatory to add this parameter. It corresponds to the id of the article from which we want to get information. If we don’t do so we get no result.
example: http://urlofmywebsite/spip.php?page=jsonpgis_one&id_article=322

It returns jsonp instead of json
example: http://urlofmywebsite/spip.php?page=jsonpgis_one&id_article=322&callback=?

Here is an example of how this jsonp looks like:

	"title":"Title of the article",
	"description":"Description of the soundscape",
	"date":"2011-10-09 13:33:47",
Este artigo escribiuno berio, publicado o 30 Xaneiro, 2012 ás 16:58, gardado en Plugins e etiquetado como , , . Garda o permalink. Segue os comentarios do artigo co RSS feed que ten.