Thursday, September 28, 2006

About OyajiMapper.js

OyajiMapper.js is a single JavaScript file which contains a set of functions to display maps using Google Maps API. I would like to call OyajiMapper as OMap for saving transmitted data in the Internet. This single JavaScript file takes care of everything OMap can do. So if you like OMap you can use it by saving the file and copying it to your website where you want to use functions of OMap. At the point of writing this entry, there are no OMap functions implemented. OyajiMapper.js is an almost empty file with only a few comments. My objective of this entry is to explain why I want to write OMap and what OMap functions will be implemented. This is an overview of OMap. I have posted entries using Google Maps API to include maps in my entries. One of such entries is this entry in TypePad. Since I don't like to see any logic or code in an blog entry which should contain only data, I implemented some functions that read position information in the HTML document and call Google Maps API to display the map. If you browse the HTML source of that entry, you will find out a div tag having id="map-35.701915,139.75498". One of my functions checks all div tags in the page using DOM. If any div tags whose IDs contains "map-", the function treat them as the places replaced by maps. The latter part of the ID is the latitude and the longitude of the place. Another function of mine calls Google Maps API to display the map. I was successfull in a sense that I could remove any JavaScript code in a blog entry. But I am not satisfied about IDs. My brief is that IDs or keys are only for machine or computer and they are never for human beings. If a program needs an ID, it should take care of itself and a blogger has not to help it. As a matter of fact, it is difficult to assign an ID to her blog entry. Because the ID should be unique in all the possible pages which contains her entry such an index page, an archive page, category pages and an individual page. And if you want two maps in your entry, you need two different IDs. Another thing I don't like is that it is not semantic. Why should part of the ID be latitude or longitude? No one can imagine the meaning of ID or a fragment of his blog entry without knowledge of the JavaScript functions implemented. Those are the reasons why I want to write another set of JavaScript functions, OMap. Let me summarize them as follows:
  1. Any JavaScript codes should be separated from a blog entry.
  2. IDs for identifying the div elements for maps should be taken care by outside JavaScript functions which need IDs. So a blogger doesn't have to write IDs in his blog entries.
  3. Only things a blogger write in her entries are place information such as latitude, longitude, name of the place and its description. And the data written in a blog entry should be written semantically.
I have written too much in a single entry. So I would like to write in another entry about what what functions will be implemented in OyajiMapper.js.

No comments: