Sunday, August 29, 2010

Squeezed some juice out of Google Maps!

HOW TO IMPLEMENT COVERAGE AREA FUNCTIONALITY BY BUILDING ON GOOGLE MAP
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 = "";
}

Wednesday, June 30, 2010

Experimenting with Adobe Creative Suites

I was on leave from my place of work (Swift Networks Ltd) from the 22nd to 30th of June. I spent all the time at home. Can you imagine? Wasn't i bored?

No, not at all!

Because i had a fun time studying and using Adobe products (Adobe Flash CS5 and Photoshop CS5). There was actually a web project on the line and instead of using what has become second-nature to me (MS Visual Studio Web Developer, Adobe Dreamweaver CS3 and pure HTML and DHTML), i decided to use the latest technologies from Adobe.

It was a most productive time for me as i had all the time in the world to concentrate on Flash. I learnt all about tweening, action script and the rest fun aspects and practically experimented with them.

The outcome is this website, www.mmaniera.com. Yea, you could say it ain't got that sparking thing about it. Don't forget, am innately a SOFTWARE DEVELOPER and the budget for the project was so small i had little apart from the company logo to contract out. The rest i did all alone!

As i go back to work tomorrow, i already have ideas i have to put to bear on my company's new website (www.swiftng.com) which is still under development