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
Anonymous



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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php // Example page from Google...
// http://groups.google.com/group/Google-Maps-API/browse_thread/thread/f8ad7eabb1c7f360/ce6844d0883dae65#ce6844d0883dae65
?>
<head>
<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAJVXjUUf9w3uK4JOTnUjtmhRflKT1ByLdAwE0qGKUfkqxDXuq4BSKI2ATTrGcUGJwR6LQ3Ut66tojRg" type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 500px; height: 400px"></div>
<script type="text/javascript">
//<![CDATA[

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

//]]>
</script>
</body>
</html>

* * * * *

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 http://www.geonames.org/export/ "

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.

Thanks.
marc



Joined: 08/12/2005 07:39:47
Messages: 4416
Offline

Hi

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

http://www.geonames.org/maps/json-googlemaps-example.html

The JSON fullt text search :

http://www.geonames.org/export/#fulltextSearch

It is important to url encode the search parameters :
http://forum.geonames.org/gforum/posts/list/8.page


Marc

[WWW]
Anonymous



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 http://www.geoworld.org/mapsSearch.php

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?

Thanks.
marc



Joined: 08/12/2005 07:39:47
Messages: 4416
Offline

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 http://www.geonames.org/export/jsr_class.js to your server and change the line accordingly.

Reference :
http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html?

An other JSON example (with yahoo instead of geonames) is here :
http://www.theurer.cc/blog/2005/12/15/web-services-json-dump-your-proxy/

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

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