Archive for the ‘Computer Science’ Category

Solution to Huge Numbers of Overlays with the Google Maps API

Friday, August 5th, 2005

Cross-posted to the Google Maps API discussion group (click here):

There has been a lot of discussion on a large amount of overlays on a single Google map. Different hacks have approached this problem in different ways. Many sites do not even deal with it because they can’t, don’t know how, or don’t want to.

The capability to display a huge amount of overlays I believe should be handled somehow by the Google Maps tool itself. However, since most, if not all of Google Maps is written in JavaScript this may be a problem. The JavaScript would have to load a large file and then query it. For JavaScript, this would take a long time if the file was large.

I’m going to explain a solution which is derived from what I’ve seen on a few different sites, and what I think would be the best. It uses PHP and MySQL, but I’m sure you could substitute in other technologies like ASP and Access, or JSP and Oracle for example. What would be an even better thing to do would be to figure out how to get a real GIS map server (Google it) to interact with Google’s native overlays, but for those of you who just need a simple solution, here it goes.

You would use PHP along with a MySQL table full of Overlay information. Then, the JavaScript would call a PHP function with the current bounds of the map which is represented by two points. It doesn’t matter how you call the function, just find a way. Then, PHP would use these two points to make a MySQL query on your table of points and only return those in the specified bounds back to the JavaScript. Then, the JavaScript would clear the map of markers and then redraw only the ones which are returned by your server (the ones that are currently in bounds).

I would appreciate questions and comments as I go ahead and implement this solution. Maybe someone has already done exactly this and open sourced their code. If so, I would love to hear about it to save me time.

-Kyle Mulka
http://maps.kylemulka.com

Update:

I forgot to discuss the problem of having too many overlays within a given bounds. That is kind of important. Oops. For example, if you are zoomed out all the way, your JavaScript will be handed all of the overlays in the world, and this will not help performance AT ALL for higher zoom levels. So, I’ll outline a general solution to this problem.

You need to organize overlays into groups. Visually, on a map, without knowing anything about the underlying data, I see only one general solution. If anyone has any others, I’d love to listen.

You would have an algorithm which reduces the number of overlays to display by automatically grouping overlays based on location. There are tons of ways to do this. I think the easiest way would be to split up the given bounds into four squares, then check each square to see if there are still to many markers in that square. If a square still has too many markers, simply divide that square into another four squares and count again. All of this information could be calculated ahead of time and stored in a database for painless and fast retrieval when queried. This is almost exactly what Google does with its map tiles. Each zoom level simply divides each tile (a square) into four smaller squares and displays the new four tiles. This is how Google Maps itself is so fast. They can simply save all of these tiles in a database or as image files for absolutely painless retrieval. There is almost no processing required on the server. It is extremely scalable.

Another improvement to this system may be to use the same system that Google uses to keep track of tiles. The tiles are cached on your computer, and when you go one way on a map, then go back, it doesn’t have to query the server for those tiles. It would be nice if you could some how cache the marker information in the browser as well.

-Kyle Mulka
http://maps.kylemulka.com

How TerraServer Works

Wednesday, August 3rd, 2005

I found this paper interesting to skim through. I didn’t actually read it. It shows a diagram of the TerraServer setup (most of the imagery used in Microsoft’s new Virtual Earth).

Don’t let the title scare you. Even if you don’t read it the pictures are pretty.

TerraServer Bricks – A High Availability Cluster Alternative

LZW File Compressor? Been There, Done That.

Sunday, July 31st, 2005

From Joel on Software:

“The assignments are very serious for a college class: implement a Unix command-line shell, implement a ZLW file compressor, etc.”

I found it funny that we did a project that was, as Joel puts it, “very serious for a college class”. It was an honors class, but oh boy, was it hard. I thought I knew C++, but I was wrong. Aparently there’s this thing called the command line, and bits and bytes. Oh, and bit shifting. Why wasn’t I taught this stuff before now? I mean, I knew that the operators meant to right shift and left shift, but I was clueless, until probably this very project as to what bit shifting actually was.

So, for those of you who care and don’t know, here is bit shifting in a walnut shell. (Its a little bit bigger than a nut shell. Oh wait, walnuts are nuts. Whatever…)

So, lets say you have a char in C++. It is represented as 8 bits. Each bit is either on or off. Remember how to count in binary? I think I learned it in fourth grade or something. Sadly, I needed to refresh. I’m not going to explain how to count in binary here. Anyway, convert to decimal, then go find an ascii table and convert to an ascii character. There you go. You have one letter in a text file.

If for example you only have 4 cahracters in you alphabet, you only need 2 bits. So, to compress this file with only four characters, you could compress the 8-bit chars to 2-bit chars by storing 4 chars within 8-bits. Since the computer, and/or C++ doesn’t work with less than 8 bits (aka a byte) at a time, we need to take the last byte in the file, move the bits over to the right spot, then do an or operation to add on the 2 bits to the end of the file.

If that didn’t make sense, maybe I need some diagrams or a better explaination. Let me know.

Oh, and when I start my own software company in the next few years, how am I supposed to hire the right people? How am I supposed to measure the programmers if the programmers can’t be measured AT ALL. Hmm… I’ll have to think about that one.

Here’s the article:
Hitting the High Notes

Ajax Mistakes

Sunday, July 24th, 2005

Here’s a good overview of some things to watch out for when messing around with Ajax, or other web technologies.

Ajax Mistakes

The mistakes that annoy me the most are the Breaking the back button, Not using links I can pass to friends or bookmark, and Blocking Spidering. I like my back button. It should work, at least most of the time. Some pages have figured out that having links that you can actually link to is a good thing. For example, in Google Maps there is a “Link to this page” feature. I’ve also made sure that you can link to people’s schedules in Mschedule. For example, here’s a link to my schedule for fall ’05. Blocking spidering can be a bad thing if the site relys on people finding it through search engines.

Innovation Like Crazy With Google Maps

Monday, July 18th, 2005

Last weekend I was working a lot with Google Maps. They are so fun to play with! I’ve created several web services. Not all of them are ready to be released yet, but if you have a GPS unit, Garmin eTrex for example, and software, like EasyGPS for example, you can upload and view GPX files.

All of my maps services will be available through this address: http://maps.kylemulka.com

If you have any suggestions along these lines, feel free to leave a comment, or send me an email or something. Thanks.

Web Design Patterns

Wednesday, July 6th, 2005

Web Design Patterns

Test Open Source Content Management Systems Without Installing

Sunday, July 3rd, 2005

Recently I’ve been looking at different Wikis at work, and I’ve found a useful site that hosts all sorts of php/mysql based Content Managment Systems. You can try out them all with their default installation. You can even have admin access to them. They are completely reinstalled every two hours, which is pretty sweet. Every two hours all possible spam and other people’s messings are cleared. Nifty. There’s a little “Count Down” timer in the corner to warn you too.

OpenSourceCMS

It’s a great time to be an entrepreneur

Thursday, June 30th, 2005

More encouragement to start a busines:

Bnoopy: It%u2019s a great time to be an entrepreneur

Google Earth – now free

Tuesday, June 28th, 2005

In my opinion there is absolutely no free software available today that is cooler than this. Google Earth, a 3D interface to the planet. Here’s some screen shots for ya:

Detroit

Grand Canyon

World Trade Center?

XUL Parser for Java

Monday, June 27th, 2005

I found this XUL Parser for Java. Of course, I haven’t tested it out, but maybe I’ll find a use for it since I agree with the page that XUL is a lot easier to read and code with than Java’s Swing GUI framework.