Question

I might have gotten in over my head here, and am looking for any possible assistance, as I am really not familiar with writing code. If you can dumb down any possible answers, that'd be spectacular.

I created a Google Fusion Table that lists worldwide sea ports by city and country, and visualizes them on a map. I want to have the ability to type in an inland location and have the map mark the location, and advise the closest one or two seaports.

For example: I enter a location of Richmond, VA, and the map will mark Richmond, VA on the map, and advise that the Norfolk, VA and New York, NY sea ports would be closest.

I'm not sure where to begin to accomplish this. Is this too vague of a question? Any help provided will be greatly appreciated!

Was it helpful?

Solution

You can accomplish this using a bit of JavaScript code. The Fusion Tables Layer in the Google Maps API allows you to find the nearest n neighbors to a latitude, longitude coordinate. An example can be found here:

https://developers.google.com/fusiontables/docs/samples/nn_example

Here are the overall steps you would take to create the app:

  1. Create an HTML page that has a search box plus a map with the Fusion Table Layer displaying the data from your table

  2. When the user enters a search term, such as Richmond VA, you would geocode the string to get the lat/lon coordinate. You can use the Google Maps API geocoding service:

    http://code.google.com/apis/maps/documentation/javascript/geocoding.html

  3. When you get the lat/lon coordinate, use this to update the query sent to the Fusion Tables Layer (similar to the example above) to show the 2 nearest ports.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top