BACKGROUND
Google Maps is a great tool for the free price and certainly, pricing will have little or no effect on the rate of adoption of this tool should there be a price tag on it.
I was faced with a situation where the only recourse is Google Maps. Basically, customers or visitors to the site I was working on should be able to check if internet service is available in their areas before taking the next step to place orders online or going to any nearby reseller locations. You can test or see how this works on the website. http://www.swiftng.com/products_services/coverage.php.
TECHNOLOGY USED
The technologies/tools below are used to implement this functionality:
1. AJAX
2. Javascript
3. WAMP (Windows, Apache, MySQL and Php)
4. Google Maps
HOW THESE ITEMS WERE MIXED TO COOK THE DELICIOUS MEAL
For a starter, php handles the server-side scripting, the duo of JavaScript and AJAX take care of the client-side scripting while all BTS coordinates (latitude and longitude points) are stored in the MySQL database. I loaded Google Maps on the web page and use JavaScript and AJAX to respond to the map’s click event. When a user clicks on any point on the map, I get the coordinates of the clicked point from Google Map and asynchronously and quietly call a server-side function that does the coverage check. An SQL script on the server uses some math function to query the database and check if the customer’s coordinates are within the 1000 kilometer of any of the Base Stations in the database. Based on the returned value, a balloon notification is displayed on the map to show service availability or not.
The trick is to sneak in the coverage-checking code into the Google Map object's click event. In that same routine, you can get the latitude and longitude of the point users click on the map, do your check and use the map's OpenInfoWindow function to display result to users.
An example of the code is:
GEvent.addListener(map,"click", function(overlay,latlng) {
if (latlng) {
var array1 = latlng.toString().substr(1).split(",");
var varLat = array1[1].trim(); //alert(varLat);
var varLng = array1[0].trim();
var result = roundNumber(varLat, 7);
varLat = roundNumber(varLat, 7);
varLng = roundNumber(varLng, 7);
//var test = map.fromLatLngToDivPixel(new GLatLng( 3.2691500, 6.4452111));
//call a checkService function
CheckService(varLat, varLng);
var myHtml = "Coverage Area Check
" + isAvailable;
//call a routine to check if this latitude/longitude is within any POP latitude + radius
map.openInfoWindow(latlng, myHtml);
myHtml = "";
isAvailable = "";
}