Kaz's Coding Examples
This example illustrates the use of the Google™ Map API as an Interface into an International Hotel/Resort Directory using basic GIS techniques. The NWS(National Weather Service) provides real time weather data to create the weather image.
Just Click the map.
International Hotel/Resort Directory
- AJAX is used to communicate and query data from the server.
- MySQL Database of Hotels.com™/Travelnow.com™ International Hotel Directory
- National Weather Services Live RSS/GIS data.
The list of hotels is retrieved in response to clicking on the Google™ Map. The Google™ Map passes the Latitude/Longitude to a call back function which combines this information with the Search Radius value, and passes it to an AJAX routine that queries a MySQL database for properties within the search radius from the point clicked on the map. The data is returned to an AJAX call back function as a executable piece of javascript that actually does the writing of the property list.
The Weather icon is a dynamic image created with PHP and a call to the National Weather Service's Live RSS feed. The javascript that is returned from the previous step will set the src attribute of the image to a php script that actually creates and returns the image data. FYI - some issues with the NWS feeds.
While I cannot take credit for the following (really cool) SQL query that does the radius search, I thought I would share it in case anyone else was hunting for one. I cut and pasted it from some news group - if you'd like to take credit for it, drop me a line. Basically, it's a trigonometry formula to find the distance between two point(as the crow flies).
SELECT id, Latitude, Longitude, (((acos(sin(($latitude*pi()/180)) * sin((latitude*pi()/180)) + cos(($latitude*pi()/180)) * cos((latitude*pi()/180)) * cos((($longitude - longitude)*pi()/180))))*180/pi())*60*1.1515) as distance
FROM Properties HAVING distance <= $distanceStill working on...
- Better error handling for weather image. The problem is that the NWS has this feed down a times, therefore I need to have something more graceful besides the missing image icon(
). Also, the NWS does not have data available outside the continental United States.
- City listbox lookup. The "State Cities:" listbox is properly populated with cities in the state, but there is no mechanism to query those cities.
- More...