Pman's Lab

Welcome to my lab.

A demonstration of what I work on during spare time. Visit the my Lab page to see what I have done so far.

View Demo»

To Do List

  • show ryerson campus on the map
  • create an xml file with campus building location
  • display markers on the map for each campus buildings
  • Modify the marker's behavious so that they only appear when the user clicks on them
  • Add Google's map type and map control
  • Set minimum zoom out level and restrict the user from dragging the entire map out of the viewing area
  • Increase the initial zoom in level
  • Rearrange the sidebar since there's too many building listed and so that the user doesn't need to scroll down to click on the sidebar
  • Add a search engine to the sidebar, so that if the user types the building name, that building will show up in the map
  • Create two custom map, one is the original ryerson map and another as hybrid of the original ryerson map and the google map
  • Modify the xml document to store the data more organized way and change the javascript file to reflect the changes on xml document.
  • Collect Information about each building in the campus and images of them to show in the info window.
  • Show building information on tabbed window, when the markers or the linkes in the sidebar are clicked.
  • Show relevant info in the map such as: parking lot, restaurants or snack store etc.
  • Divide the sidebar into several parts so that each section will contain the following: classroom buildings, information buildings, quick search, relevant info
  • Fix window resize problem for the map
  • Change the background color of the map according to which sidebar element is active
  • Instead of having all the loactions in one xml file, seperate them into different files and load them depending on which sidebar is clicked.
  • Load the xml only when the associated sidebar is clicked.
  • Get a proper category list for each buildings. For example, whether the Book Store should be under information buiildings or relevant or other category.
  • Fix sidebar problem for IE. The group's bottom doesn't appear properly, there's about 2/3 pixels of gap between the sidebar and the map and in both browsers, classroom group doesn't minimize on first click.
  • If the user is viewing the map in less than 10/12(untill we see the whole toronto area), show a marker on the map.
  • If the user is viewing from 10/12 to 14 level zoom, then draw a transparent colored rectangle as an overlay over the campus area
  • Create maps for level 15+, slice it, and rename properly.
  • Update the xml file and placing marker to use new geocoder tool/api from google.
  • In the info window, show a Form for getting driving direction and redirect this info to google map website where the driving direction will be displayed.
  • In Classroom Building sidebar, make a tab for offered programs or departments, which will list the those departments and load the associated buildings from another xml file.

Journal

Thursday, June 1, 2006 - Get started with the map

I have just got the api key from google now and read a few tutorials on how to use the api. So, I actually didn't do any of the work yet. That's why, I'll just start with the very basic right now. I'll have the map on the page with ryerson campus by default. In order to do that I will need the geocode or the latitue and longitude geographical info. for the campus. I should be able to find that online. By the way, just in case I loose this, here's my api key from google for using their map api.

Time: 45 min.

Everything went good so far. Didn't have much trouble getting the map show up on the page with Ryerson Campus by default. I had to get the geocode from GeoCoder.ca. Since the campus has so many buildings, I'll just create an xml document with their geocode and then load it in the map with markers.

Friday, June 2, 2006 - Make XML file

Right now, I'll just create an xml document that will have the location of all the buildings of ryerson campus. This xml document can be loaded by google's api and then the location can be used to place marker on the map to show the building loaction. Mike already has a nice example of this. Although I'll be learning this from his code, I'll probably still take a look at google's documentation on loading xml.

Time: 1 hour 30 min.

Only created the xml file with the latitude and longitude information of all the buildings of the campus. But, I was discouraged to see that Ryerson already has a map with 1 level of zooming and somwhat dragging enabled map, which was made in flash. Well... I'll continue working on this and try to make it better. Next time I'll load the xml file and then add those markers on the map. That's it for now. Later...

Friday, June 2, 2006 - Load XML using google api

Last time I created the xml file with longitude and latitude information of all the buildings in the campus. Now it's time to parse the xml file and create a marker for each of them. Right now I'll just have the marker show up right away, but later I'll work on hiding the marker so that they show up only when the user clicks on the building name.

Time: 1 hour

Loading XML and then creating the markers at those points are done. I used Mike's example, but I'll be modifying it later. The way it works now is that it will add the markers right away after loading the xml. But I'll get rid of the markers and have the markers show up after the user clicks on the building names on the side. Also, I will set the clicked marker be at the center of the map.

Modify Marker Behaviour

Modify the marker behaviour to make the map more interactive. Set the center of the map to the point where the marker is set.

Time: 2 hours

Just finished modifying the markers so that they only appear when the user clicks on the name of the buildings. Had a little bit of trouble modifying it, but at least I didn't waste too much time compared to the other projects. I did have the map set to center where the marker is, but if I do that then I loose the smooth animation, which map api performs automatically if the marker is outside the map area. I commented that part now, but later may be I'll do my own set center function to get the smooth translation

Add Map Control

Now I'll be adding the control to zoom in/out and the different map type offered by google map such as Hybrid, Sattelite etc. This should be easy

Time: 15 min.

The controls were added, but as I was playing around the map with the control, I realize that I should probably set the default zoom level to 17, which is now set to 16. Also, it appears that the zoom level changes between different types of map, for example, from Map type to Satellite Type.

Modify XML document

First, I'm going to modify the xml document to make it more useful because right now the structure of the documents is like this: 1 element for each marker with attributes that contain all the info I need. I will change this and make it proper xml so that the marker name and any html info is not part of the attrubute anymore. They will be as elements. After the xml document is modified, I'll be working on the javascript again so that everything works just like it is right now.

Time: 1 hour 15 min.

That's done as well, without a lot of trouble. While at it, I also increased the initial zoom level to 17 when the page loads. It was a little painful to type the whole xml document, but it still works. Gotta think about what to do next.

Divide the sidebar

As I mentioned earlier, since there's a lot of buildings in the campus, the sidebar becomes extremely long and it's annoying if the user have to scroll down to click on a building's name to see it's location on the map which is at the top of the page. Besides, there's more features that will be added later such as search engine, parking lot info etc. That's why, I'll redo the sidebar and information will be organized into groups, which can be hidden and show only when the user need anything from that group.

Time: 2 hours 30 min.

Well... I probably took more than 2.5 hours, cause I had to go eat dinnar and then do something else. But anyways... so far everything is looking good. The interface will probably look a lot cleaner when I change the banner at the top of the page but What I wanted to do with the sidebar, Mission Accomplished. I'll be honest, I was actually following gmail's interface because I think they have the simplest interface of all that is very veryyyyyy user friendly and that's why didn't hesitate to walk into their path.

Saturday, June 3, 2006 - Seperate the XML

Once again, I have to modify the xml file. But this time, it should be easier, because I don't have to type up anything, simply copy the inappropriate location to the proper xml file. For example, in the classroom xml file, only the classroom buildings should be listed and in the infoLocation xml file, only the information providing buildings will be listed such as Student Centre. Once they are done, load the xml files, parse them and place them in appropriate sidebar.

Time: 30 min.

Fortunately, there wasn't any trouble on this part and finished it rather quick. The campus.xml file has been divided into two different file as planned and both xml files are being loaded right now, but the building lists show up under proper category list. However, there are some building, whose category is hard to define, but I'll worry about those later since they can be changed at anytime by just placing their info in the appropriate xml file.

Sunday, June 4, 2006 - Fix sidebar problem for IE

After I finished working on this project last time, I checked the page on IE, and found out that the sidebar, where the group for each building is loacated, isn't working properly in IE. For example, by default the group of classroom buildings are showen, when the page is loaded, but if I click on the other group to see those buildings, they wouldn't show up. I think it's because I added a js line for the click event so that the div for the map has the same class as the group that is clicked and they both have the same background. I used object.classname = "something". I think IE doesn't work this way. Going to solve this right now. Also, I noticed that IE leaves about 2/3 pixels of gap between the sidebar and the map area, which is suppposed to be together. This should be fixed as well.

Time: 3 hours

Spent a lot of time, but couldn't fix the main issues. I did fix the background matching issue and it wasn't because of object.classname; That was fine. I played with the css a lot, but can't find out where those gaps are coming from between the sidebar and the map area. Also, in IE, the bottom 4/5 pixels doesn't show up for some reason. This is one of the wierdest problem I've seen so far. Spent 3 hours and still couldn't fix everything in this issue. Arrggggggg.....

Monday, June 5, 2006 - Create Custom Map

Okay, this is one of the major part to this project and this one will take a LOT OF WORK. I'm not worried about the javascript part, because the api's will do all the complicated part for me. All I have to do is follow the steps and place the appropriate url that will get the images for the map. This image part is the one that I'm worried about, because I'll need lot's of tiles or images based on the zoom level. But I'll just get the structure done, for now, so that the custom map option appears on the top and the user can switch between map types. I'm going to follow the tutorial from http://www.mapki.com/wiki/Add_Your_Own_Custom_Map

Time: couple of months

This took a long time to finish. But, it's not that hard anyways. The hardest part is to get you own custom map drawn in Illustrator or Photoshop, scaling the map for different levels of zoom and slicing it accordingly, well... at least for me since I'm not a graphics person. That was basically the main problem I was having. Besides, I also had to do some research on how to add a custom map and also study some source codes.

Wednesday, August 9, 2006 - Collect Information

Now that the map is up and running with the custom map that I made, I'll be working on collecting information for each buildings such as: building images, address etc. These information then will be shown in the info window which shows up when the user clicks on any of the building names from the sidebar.

Time: 7/8 hours

You might be wondering why it took me that long to collect the building informations. Well... as I was researching about building's information in the campus, I kinda got carried away a little further. At first I only wanted to show an image of the building and the address of that building in the info window. But later, I thought, it would probably be more useful, if I also showed the faculties or department's offices in that building. For example: Industrial Engineering and Chemical Engineering, both faculties are located in KHS building. So, I added that to the information list. A little later again, I thought why not also show an option to get a driving direction to/from this address? Now everything was going smooth until I placed it all in the actual info window of google map marker. The problem is, first of all, the window becomes too big, secondly and most importantly, some parts of the content was showing up outside of the info window. I fixed as much as I could but I couldn't get the content of getting driving direction to stay within the info window. So, I just decided to use tabbed info window instead, which will also keep the contents more organized, for example: one tab for the address, one tab for the list of faculties in that building and another to get the address for driving direction. This way all the contents will stay within the info window, since there's less content in each tab and also the info window will not be too big. Moreover, the user will only view or click on the tab that they are interested in.

Thursday, August 10, 2006 - Display Tabbed Info Window

Last time when I was working, my info winodw was getting too big and I was having problem with the CSS within the info window for IE mainly. So, this time, I'll try to organize my data and show it in the tabbed info window. So, the first tab will have building image and address, the second tab will have list of programs or departments in that building and the third tab will offer a form to get a driving direction at that location. I'll be working on the third tab later, but for the first two, I will need to update the xml data once more and restructure it. So, basically, for each htmlInfo node, there will be childNode called Tab as many times as I need, and inside each tab node, I will have a tag for tab label and another tag that will contain the html contents of that tab. When the marker or the sidebar links are clicked, these information should appear in their own tab, which is in the info window.

Time: 6 hours

hmm... It took longer than I expected and still it's not 100% done yet. I modified the xml document and then updated my javascript file to reflect that change. But, I made some syntax error along with a little logic error, which is why, the javascript file wasn't even loading at all. It took me quite a while to figure out where the problems were and when I fixed that I was faced with another problem, which is still not solved yet. At first the tabbed window was showing up properly, but later I found out that, the tabs are duplicated each time I click on the marker. I fixed that but now the problem is that wrong tabs are showing up for the markers. I'm sure it's a logical problem within my code, which I have to figure out. In the mean time, besides reading Mike's Tutorial, I was searching Google Map API Group for information on tabbed info window and found an excellent source for tabbed window, which has an example of tabbed info window that matches excatly what I wanted to do. If you click on the sidebar links or the markers, the tabbed info window will appear with the data which was loaded from a xml document file. I was trying to do the same. I haven't studied his source code yet, just glanced at it. First I'll try to solve the problem myself, since I think I'm pretty close to getting it done. If I can't, I might have to study the source code of that site.

Friday, August 11, 2006 - Fix Tabbed Window Problem

Previously, I was having problem with tabbed window that appears on top of the markers when they are clicked. Wrong tabs were showing up for each markers. I will try to fix this problem now.

Time: 1 hour

Nice... I actually fixed the problem myself. The example that I found yesterday, I didn't need to consult that. The tabs are working fine now. The issue was regarding some array, which needed to be emptied before they were being used again. This is how I have the tabbed window working now...

//read the xml document and get the tag that contains the tab elements
....
/**
 * Since the htmlInfo element also has multiple elements for tabs,
 * loop over its child elements and save all the tabs in an array
 */
var html = markers[i].getElementsByTagName("htmlInfo");
var tabs = html[0].getElementsByTagName("tab") ;
var tabLabel ;
var tabContent ;
var infoTabs = [] ;
var infoTabContents = [] ;

for (var j = 0 ; j < tabs.length ; j++)
{
	//now, for each tab's get it's label tag and content tag
	tabLabel = GXml.value(tabs[j].getElementsByTagName("tabLabel")[0]) ;
	tabContent = GXml.value(tabs[j].getElementsByTagName("tabContent")[0]) ;
	
	infoTabs.push(tabLabel) ;
	infoTabContents.push(tabContent) ;
}
var tabbedWindow = [] ;
for (var j = 0 ; j < infoTabs.length ; j++)
{
	tabbedWindow.push(new GInfoWindowTab(infoTabs[j], infoTabContents[j])) ;
}
createMarker(point,label,outputLocation, tabbedWindow);
infoTabs = removeArrayContent(infoTabs) ;
infoTabContents = removeArrayContent(infoTabContents) ;
tabbedWindow = removeArrayContent(tabbedWindow) ;

function createMarker(point,name,sidebarObjId, markerTab)
{
// this variable will collect the html which will eventualkly be placed in the sidebar
var sidebar_html = "";
var marker = new GMarker(point);
var tabs = [] ;

GEvent.addListener(marker, "click", function(){
	marker.openInfoWindowTabsHtml(markerTab) ;
});
....
}
			
			

Anyways... It probably took about half an hour. After that, I made the CSS for the contents of the tabs. Now all I have to do is, place the tabs and its contents for all the other markers in the xml document. Oh... yea, another thing needs to be done for this tabbed window is the form for getting driving direction. That should be alright.

Display Tab Contents

Now that the tabbed info window for the map is up and running properly, all I have to do is type the collected building informations in the xml document. I will probably make a separete tab for information centers in each classroom buildings.

Time: 6 hours

Phew... finally I finished it. It took a long time to put all those informations in the xml file. I had to look for the building images, find websites for each departments and also, I had to get the geocode information for each butildings since some of them were pointing at the wrong place. When I first started this project, I used GeoCoder.ca to get the geocode for the buildings. In this site, you specify the address and it will return the lattitude and longitude informations. Since some of the geocode information was wrong, I used Get Lon Lat too provided by Mapki, where you simply click on the map and it will return the geocode information of the clicked place on the map. And I took the images of the buildings from Ryerson's Campus Map webpage. And I still have to do the same to information building's xml file.