Google Maps Satellite Shot

I was able to get a screen capture of my neighborhood and house using the satellite features of Google Maps.

If you’d like to see the full screenshot with notes you can take a look here.

The satellite feature of Google Maps is very handy even though the maps are a little outdated. I was able to figure that the data in the maps was about 2-2 1/2 years old by looking at this map. It is a view of Texas Tech University, specifically the English, Philosophy, and Education building being built which occurred a few years ago. Still, the satellite view is very nice.

San Francisco to Regulate Blogging?

According to this San Fransisco may take steps to regulate blogging. The initiative would require local bloggers to register with the Ethics Commission and report all blogging costs that exceed $1,000. So they are making bloggers mean freelance journalists, seems kind of stupid if you ask me.

I guess the next logical question is the actual enforcement of something like this. How are they going to know if someone really is in San Fransisco? What is the fine if you do not register with the Ethics Commission?

I don’t think this will ever take off due to the fact that it will probably never gain legitimacy (the acceptance and backing of the people).

Simple XMLHttpRequest Code

I have been playing with XMLHttpRequest a bit more and have created a simple application that is available here. Using a free database of zip codes and their corresponding cities and latitudes and longitudes I created a simple application that calculates the distance between two zip codes.

Notice, the page does not reload when you click the “Calculate” button, it simply fills in the blank even though it is making a database call.

index.html:

<!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" ><head>

<mce:script language="javascript" type="text/javascript">

<!--
var url = "getDistance.php?";
function handleHTTPResponse(){
if(http.readyState == 4)
{
var xmlDocument = http.responseXML;
var distance = xmlDocument.getElementsByTagName('miles').item(0).firstChild.data;
document.getElementById('distance').value = distance;
//document.getElementById('url').value = url;
}
}

function updateDistance(){
url = "getDistance.php?";
var zip1 = document.getElementById("zip1").value;
var zip2 = document.getElementById("zip2").value;
url = url + "zip1=" + escape(zip1) + "&#038;zip2=" + escape(zip2);
http.open("GET", url, true);
http.onreadystatechange = handleHTTPResponse;
http.send(null);
}

function getHTTPObject()
{
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp &#038;& typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
xmlhttp.overrideMimeType("text/xml");
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
// --></mce:script>
</head>
<body>

<form action="post">
<p>First Zip Code:</p> <input type="text" size="5" name="zip1" id="zip1" /> <p> Second Zip Code:</p> <input type="text" size="5" name="zip2" id="zip2"/> <p> Distance:</p> <input type="text" size="10" name="distance" id="distance"/> <input type="button" value="Get Distance" id="submit" onclick="updateDistance();"/> </form> </body></html>

In this code we are simply creating the Javascript objects that we’ll need to do the calculation. The updateDistance() function does a lot of the easy work, simply setting the values pulled from the form. handleHTTPResponse() does most of the heavy lifting, getting the values from the called PHP that returns a basic XML file.

PHP:

This PHP file does the actual work. It pulls the needed values from the database, then calculates the distance using the Great Circle Distnace formula. It then returns an XML file that is called by the above Javascript.

Generated XML file:

It’s a very simple XML file that returns the basic data needed. The most important field is the ‘miles’. It is a rounded distance returned by the distance formula.

So that’s that in a nutshell. It is a lot simplier than it looks and it gets the job done. Of course there are downsides to using XMLHttpRequest and you can do a search on Google for such reasons (maybe that will be my next post, “The downfalls of XMLHttpRequest”).

If you have any questions about how all of this works feel free to e-mail me at s [at] badice [dot] com.

Don’t Call it That!

As I mentioned in my last post I mentioned starting to play with Ajax. Well, I have been informed that “Ajax” is a “stupid name”.

Ajax is a name for the grouping of XMLHttpRequest, DOM, and CSS together to create web applications that run seamlessly with the backend to add dynamic information to the page.

Well, the Ajax name was first used by the folks at Adaptive Path, who some believe coined the term just to get their name out there.

Do I really care? Not really, I know that I want to use XMLHttpRequest, DOM, and CSS to do some new and cool things and that’s that. I don’t really care about the name. I could just give it a name that suits me so that I don’t have to read out “We’ll be using XMLHttpRequest, DOM, and CSS” because that’s a mouthful (hmmm, maybe that’s why Adaptive Path came up with the name).

Playing With Ajax

I am going to be doing some playing with Ajax over the next few days and hopefully I will get some code examples up when I have the chance.

My current dilemma is figuring out whether or not Ajax is what I need and where it could be useful and where it would be cumbersome. I know that as a whole it is a very awesome technology, just the fact that a page does not have to be reloaded to perform a server side action is amazing. The real issue is how usable is Ajax and what applications could I use it in.

The first type of application where it would be extremely useful is something that requires a lot of user input. If you can limit the amount of input needed from the user and limit the number of times they have to use their mouse to click a button the more productive they become. The one application that comes to mind is the user’s interface on Flickr. If you want to edit a picture’s title or description you just have to click on the text, edit it, and click the “save” button. There is no clicking on a “Edit this picture” button or link and there is no need to fill out form fields that don’t need to be edited, it’s all done right on the same screen. Very convenient and to me, intuitive. It makes sense to edit things like that on the page in which the show up. Plus, you are not taxing the server (as much) because you do not have to reload the page, recalling all of the information that you already have up, you just have to reload the information that was changed.

It is just a very interesting concept and suprisingly easy to understand (the concept at least). I guess the next thing on my purchase list is a JavaScript book.

So What’s This “PowerBook Fund” Thing?

If you are a regular reader of my blog then you probably noticed the “PowerBook Fund” piece on the left side. I’ll explain.

I am in the market for a 15″ PowerBook. Being an MIS student leaves me needing something to code on while I’m in class. I like being able to do what the professor is doing on screen and since all of my classrooms do not have computers sometimes I just do not have the opportunity to be the “hands-on learner”.

I have started my own little saving for the PowerBook but thought I would open it up for donations. I plan on buying a base 15″ model with a RAM upgrade. If you’d like to contribute feel free, any amount is greatly appreciated. I am going to be adding some stuff to the sidebar to convey my goal and how close I am to reaching it.

I am not the type for handouts but I really felt like asking loyal readers for contributions would not be a huge deal. The Google AdSense ads do not bring in a ton of money (very little actually) and contributions seem like a viable option.

If you have any questions about all of this you can e-mail me at s [at] badice dot com.