Connectie naar de nuraghe database

Deze pagina is in het engels en wordt binnenkort aangepast en vertaald!! offers the possibility to connect to the database of Sardinian nuraghi and retrieve the information from this database to create your own pages either with Google maps or by using the resultset for your own tables and combine them with your own information. The database contains information on the geographical position (latitude,longitude,altitude) of the nuraghe, as well as province and place where the nuraghe can be found. At different zoom levels the returned values will be aggregated (clustered), by province or by place, or it will return the positions of the nuraghi within the specified geographical coordinates (viewport of the map). You can define your own code or use the examples on this page to create your own pages. You will need to have some experience with Google Maps API v3 to be able to use this code.

Conditions of use

To start using the connection to the database just subscribe by using the registration form (temporarily disabled). The use is free under the condition that a reference is put on your page to this site. The code samples are free to use under the GNU General Public License. You can register as many websites as you like. The url will only return a value if your domain is registered using the registration form.

How to retrieve the output from the database

The url

The url to use is:

where lvl is the zoomlevel, which can be anything between 0 and 18, and the latmin,latmax,lonmin and lonmax are the four corners of the geographical area, the viewport, which you only need to specify if the zoomlevel is 12 or higher.

Return values

The return values depend on the zoomlevels. Anything lower than zoomlevel 10 will return the number of nuraghi by province, and 10 and 11 by place. You will obtain the following results:

A. Zoomlevel lower than 10:

  • prov = name of the province
  • count = the total number of nuraghi of that province
  • lat = latitude of the averaged center of the nuraghi
  • lon = longitude of the averaged center of the nuraghi

B. Zoomlevels 10 and 11:

  • prov = name of the province
  • count = the total number of nuraghi of the place
  • lat = latitude of the averaged center of the nuraghi
  • lon = longitude of the averaged center of the nuraghi
  • place = the name of the place

C. Zoomlevels 12 and higher:

  • id = identification number of the nuraghe
  • name = name of the nuraghe (without the word nuraghe)
  • prov = name of the province
  • place = name of the place
  • IGM = coordinates on the map of the Istituto Geografico Militare
  • lat = latitude of the nuraghe
  • lon = longitude of the nuraghe
  • alt = altitude in meters of the nuraghe according to Google Earth
  • image = path relative to of the image resource (if available)

You can use any of these return values for your own purpose. The data is returned in XML format and looks something like this (example at zoomlevel 8):


Creating a map with the data

With Google Maps v3 it is no longer necessary to request an API key. You can use the code directly without having to register. You have to define a map on your page. To retrieve the four angles of your map use the following code in javascript (where mymap is a reference to your map definition):

var bounds = mymap.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var nLatMax =;
var nLatMin =;
var nLonMax = northEast.lng();
var nLonMin = southWest.lng();

To get the current zoomlevel of your map use this:

var curZoom = mymap.getZoom();

Define an array to hold the data returned by the xml, it is best to define this at the highest level to make the variable global:

var markerArray = [ ]

Combine this into a call to nur2xml.php using the function DownloadUrl (You can also use jquery and ajax). Note that for the three different zoomlevels the array is filled with different data:

function downloadUrl(url,callback) {
   var request = window.ActiveXObject ?
   new ActiveXObject('Microsoft.XMLHTTP') :
   new XMLHttpRequest;
   request.onreadystatechange = function() {
      if (request.readyState == 4) {
         request.onreadystatechange = doNothing;
         callback(request, request.status);
   };'GET', url, true);

function doNothing() {} ;

downloadUrl(""+curZoom +"&latmin="+nLatMin+"&latmax="+nLatMax+"&lonmin="+nLonMin+"&lonmax="+nLonMax, function(data) {

var ncurZoom = mymap.getZoom();// capture the zoomlevel
var var nurxml = data.responseXML.documentElement ;
var nurmarkers = nurxml.documentElement.getElementsByTagName("marker");
if(nurmarkers.length > 0){

   for (var i = 0; i < nurmarkers.length; i++) {

      if(ncurZoom < 10){

         // returns province, count, and central coordinates
         markerArray.push([nurmarkers [i].getAttribute("prov"), nurmarkers [i].getAttribute("count"), nurmarkers [i].getAttribute("lat"), nurmarkers [i].getAttribute("lon")]);

      }else if(ncurZoom < 12){

         // returns place, province, count and central coordinates
         markerArray.push([nurmarkers[i].getAttribute("prov"), nurmarkers[i].getAttribute("count"), nurmarkers[i].getAttribute("lat"), nurmarkers[i].getAttribute("lon"), nurmarkers[i].getAttribute("place")]);


         // returns each individual nuraghe and it's position
         markerArray.push([nurmarkers[i].getAttribute("id"), nurmarkers[i].getAttribute("name"), nurmarkers[i].getAttribute("prov"), nurmarkers[i].getAttribute("place"), nurmarkers[i].getAttribute("IGM"), nurmarkers[i].getAttribute("lat"), nurmarkers[i].getAttribute("lon"), nurmarkers[i].getAttribute("image")]);




You can use this array to create markers. If you put it in a separate function, for instance LoadNuraghi(), then you can refresh the map every time with a function like this one:

google.maps.event.addListener(mymap, "idle", function() {loadNuraghi();});

You will find much of this code also on my page NuraghiMap.php and in the javascript file maps_v3.js along with some more code I created. I can provide support through Facebook

Laatst gewijzigd 27/05/2020

Reisgids mee?

Download Reisgids
©2019 Sitemap Privacy Contact