New user?

Generating maps from live data

The following map is generated live from this page. It shows the countries MapsGeek users are from. This page gathers the information, builds the URL and display the map.

Generating the script to build this map

The URL has to contain the following information :

This page is written in PHP, here is the full script to generate this map:
<?

// The base URL containing the map and l1 parameters and introducing the dl1
$url "http://www.mapsgeek.com/live.php?map=gvux92r58surqfkx&l1=1023&dl1=";

// The query to gather the information
$query "select COUNTRY, count(USERS) NBU from USERS group by COUNTRY";
$dbresultmysql_query($query$connection_to_database);

// The loop building the dl1 parameter
while($row mysql_fetch_array($dbresultMYSQL_ASSOC))
{
    
$obj urlencode($row[COUNTRY]); //Encoding the country name, storing in $obj
    
$val $row[nbu]; //Storing the number of users into $val
    
$url .= "$obj:$val;"//Adding the $obj (country), followed by ':', the $val (number of users), ended by ';'
}

// Displaying the url obtained inside an image tag (and a link to mapsgeek page also)
print("<a href=\"http://www.mapsgeek.com/map/gvux92r58surqfkx\"><img src=\"$url\"></a>");

?>


The URL obtained is :

http://www.mapsgeek.com/live.php?map=gvux92r58surqfkx&l1=1023&dl1=Argentina:1;Australia:6;Austria:1;Barbados:1;Belgium:7;Bolivia:1;Brazil:1;Bulgaria:1;Cameroon:1;Canada:9;China:1;Croatia:1;Czech+Republic:2;Ecuador:1;Finland:1;France:78;Germany:6;Hungary:3;India:8;Indonesia:2;Ireland:1;Italy:8;Kuwait:1;Malaysia:1;Mali:1;Martinique:1;Mayotte:1;Mexico:2;Montserrat:1;Morocco:1;Netherlands:4;Nicaragua:1;Norway:1;Pakistan:1;Philippines:1;Portugal:2;Russia:1;Senegal:1;Serbia:1;Spain:2;Switzerland:3;Ukraine:2;United+Kingdom:18;United+States:120;Venezuela:1;

More help

You can get more help in the forum

Creative Commons License MapsGeek, 2009.       Disclaimer       Privacy Policy       Terms of Service
Maps on MapsGeek are licensed under a CC Attribution-Noncommercial-No Derivative Works 3.0 USA License.