GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Integrating GeoNames with Google Maps  XML
Forum Index -> General
Author Message

I just subscribed to Google Maps. Below is my web page's source code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<?php // Example page from Google...
<script src="" type="text/javascript"></script>
<div id="map" style="width: 500px; height: 400px"></div>
<script type="text/javascript">

var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.centerAndZoom(new GPoint(-122.1419, 37.4419), 15);


* * * * *

I would like to add a feature that would allow visitors to navigate to a location by typing in coordinates or place names (cities, states, nations, mountains, etc.). Someone on Google's forum suggested I use JavaScript input boxes for geographic coordinates, but they suggested GeoNames for place names:

"As for placenames, personally I would recommend integrating with a
webservice like the 'Fulltext search' at "

Can someone tell me how I would use GeoNames to add such a feature to my website? Can you point me to a tutorial or a working model? I work with PHP and MySQL on a Windows XP platform.


Joined: 08/12/2005 07:39:47
Messages: 4271


There is a very basic example using the geonames JSON full text search with google maps :

The JSON fullt text search :

It is important to url encode the search parameters :



I've been studying the samples, but I'm missing something. I copied the source code from the example page you cited and inserted my own API code. The result is at

I presume I have to subscribe to some sort of GeoNames service before I can type in place names, but I haven't yet found instructions for subscribing. What do I do next?


Joined: 08/12/2005 07:39:47
Messages: 4271

The example is using a JSON script utility class written by Jason Levitt.

one of the first lines of the html page of the example :

<script type="text/javascript" src="/export/jsr_class.js"></script>

You have to copy the file to your server and change the line accordingly.

Reference :

An other JSON example (with yahoo instead of geonames) is here :

You don't have to subscribe for geonames. The service is entirely free. But we reserve the right to come back to you with this once your site is the 'Next Big Thing' and your users are hammering our servers with search requests

Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team