Demonstration of a script to make maps with annotations
Overview
This is a demonstration of a script to make maps with annotations. With it, you can put pins and annotations on any map image by specifying the latitude and longitude for each pin. When you click a pin, the annotation is pinned and kept shown.
Annotation data is embedded in HTML as CSV, Markdown, or JSON data. Each record of annotation is composed of latitude, longitude, and contents to be shown. You can use any map image of Mercator projection. By specifying the latitude and the longitude of the top-left corner and the bottom-right corner respectively, the cordination of each pin can be calculated accordingly.
Read the source code of this page to understand details of how to use it. The following points are essential.
- Loads the JavaScript file mapannotation.js.
- Loads the CSS file mapannotation.css.
- Embeds CSV/Markdown/JSON annotation data as an undisplayed element.
- Puts a map image, whose onload atttibute calls the renderMapAnnotations function.
- Specifies the longitudes and latitudes of the top-left corner and the bottom-right corner in the parent element.
As the above script is released as an open-source code under the MIT licnese, you can use it by copying the files. It's easy to modify presentation details by editing the CSS.
As The map images in this page are from OpenStreetMap, you can copy them without any permission. You can obtain map images of any regions by captureing screen images. To check the latitude and longitude of the corner points, right-clicking the same locations on Google Maps is easy.
Annotation data in CSV
You write annotation data as an undisplayed HTML element. The simplest format is CSV.
45.5231,141.9360,Cape Soya,The northernmost cape of Japan.,img/souya.jpg
38.2682,140.8694,Sendai city,Beef tongue tastes good.
35.6895,139.6917,Tokyo prefecture,Residence of Shogun.,img/tokyo.jpg,https://en.wikipedia.org/wiki/Tokyo,hotspot
34.6864,135.5197,Osaka prefecture,Kitchen for people.,img/osaka.jpg img/amemura.jpg
30.9956,130.6644,Cape Sata,The southernmost cape of Japan's main lands.,img/sata.jpg
40%,30%,Sea of Japan,Inner sea surrounded by Asian continent and Japanese archipelago.
Annoation data in Markdown
You can represent annotation data in the table format of Markdown.
|45.5231|141.9360|Cape Soya|The northernmost cape of Japan.|img/souya.jpg
|38.2682|140.8694|Sendai city|Beef tongue tastes good.
|35.6895|139.6917|Tokyo prefecture|Residence of Shogun.|img/tokyo.jpg|https://en.wikipedia.org/wiki/Tokyo|hotspot
|34.6864|135.5197|Osaka prefecture|Kitchen for people.|img/osaka.jpg img/amemura.jpg
|30.9956|130.6644|Cape Sata|The southernmost cape of Japan's main lands.|img/sata.jpg
|40%|30%|Sea of Japan|Inner sea surrounded by Asian continent and Japanese archipelago.
Annotation data in JSON
Sendai city
Beef tongue tastes good.
Seeya!
"
},
{
"latitude": 35.6895, "longitude": 139.6917, "label": "Tokyo prefecture",
"text": "Residence of Shogun.", "images": ["img/tokyo.jpg"],
"links": ["https://en.wikipedia.org/wiki/Tokyo,hotspot"],
"style": "hotspot"
},
{
"latitude": 34.6864, "longitude": 135.5197, "label": "Osaka prefecture",
"text": "Kitchen for people.", "images": ["img/osaka.jpg", "img/amemura.jpg"]
},
{
"latitude": 30.9956, "longitude": 130.6644, "label": "Cape Sata",
"text": "The southernmost cape of Japan's main lands.", "images": ["img/sata.jpg"]
},
{
"yratio": 0.4, "xratio": 0.3, "label": "Sea of Japan",
"text": "Inner sea surrounded by Asian continent and Japanese archipelago."
}
]
]]>
Map of the whole Japan and all prefecture capitals
|43.06417|141.34694|Hokkaido|Japan's northernmost prefecture, known for its vast nature and cold climate.||https://www.pref.hokkaido.lg.jp/
|40.82444|140.74000|Aomori Prefecture|Japan's top producer of apples, famous for the Nebuta Festival.||https://www.pref.aomori.lg.jp/
|39.70361|141.15250|Iwate Prefecture|The largest prefecture in Japan by area, featuring rich natural landscapes.||https://www.pref.iwate.jp/
|38.26889|140.87194|Miyagi Prefecture|Developed around Sendai City, famous for the Tanabata Festival.||https://www.pref.miyagi.jp/
|39.71861|140.10250|Akita Prefecture|A region where unique traditional culture, such as Namahage, thrives.||https://www.pref.akita.lg.jp/
|38.24056|140.36333|Yamagata Prefecture|A major producer of cherries, with many hot spring resorts.||https://www.pref.yamagata.jp/
|37.75000|140.46778|Fukushima Prefecture|A prefecture rich in the history and nature of the Aizu region.||https://www.pref.fukushima.lg.jp/
|36.34139|140.44667|Ibaraki Prefecture|Known for Mito Natto and Kairakuen Garden.||https://www.pref.ibaraki.jp/
|36.56583|139.88361|Tochigi Prefecture|Famous for Nikko Toshogu Shrine and gyoza dumplings.||https://www.pref.tochigi.lg.jp/
|36.39111|139.06083|Gunma Prefecture|Home to many famous hot springs, including Kusatsu Onsen.||https://www.pref.gunma.jp/
|35.85694|139.64889|Saitama Prefecture|Located north of Tokyo, developed as a commuter town.||https://www.pref.saitama.lg.jp/
|35.60472|140.12333|Chiba Prefecture|Home to Tokyo Disney Resort and Narita Airport.||https://www.pref.chiba.lg.jp/
|35.68944|139.69167|Tokyo Metropolis|Japan's capital and the political and economic center.||https://www.metro.tokyo.lg.jp/|hotspot
|35.44778|139.64250|Kanagawa Prefecture|Home to many tourist spots, including Yokohama and Kamakura.||https://www.pref.kanagawa.jp/
|37.90222|139.02361|Niigata Prefecture|Famous for rice production and heavy snowfall.||https://www.pref.niigata.lg.jp/
|36.69528|137.21139|Toyama Prefecture|Boasts beautiful scenery of the Tateyama Mountain Range.||https://www.pref.toyama.jp/
|36.59444|136.62556|Ishikawa Prefecture|Centered around Kanazawa City, rich in traditional culture.||https://www.pref.ishikawa.lg.jp/
|36.06528|136.22194|Fukui Prefecture|Famous for the Dinosaur Museum and Echizen crab.||https://www.pref.fukui.lg.jp/
|35.66389|138.56833|Yamanashi Prefecture|Located north of Mount Fuji, known for its wine production.||https://www.pref.yamanashi.jp/
|36.65139|138.18111|Nagano Prefecture|Home to the Japanese Alps, a popular summer retreat.||https://www.pref.nagano.lg.jp/
|35.39111|136.72222|Gifu Prefecture|A prefecture preserving historic townscapes like Hida-Takayama.||https://www.pref.gifu.lg.jp/
|34.97694|138.38306|Shizuoka Prefecture|Located south of Mount Fuji, known for tea production.||https://www.pref.shizuoka.jp/
|35.18028|136.90667|Aichi Prefecture|Centered around Nagoya City, with a developed industrial sector.||https://www.pref.aichi.jp/
|34.73028|136.50861|Mie Prefecture|Famous for Ise Shrine and Matsusaka beef.||https://www.pref.mie.lg.jp/
|35.00444|135.86833|Shiga Prefecture|A nature-rich region centered around Lake Biwa.||https://www.pref.shiga.lg.jp/
|35.02139|135.75556|Kyoto Prefecture|A city where history and culture from a thousand years ago remain.||https://www.pref.kyoto.jp/
|34.68639|135.52000|Osaka Prefecture|A major commercial city with a rich food culture.||https://www.pref.osaka.lg.jp/
|34.69139|135.18306|Hyogo Prefecture|Developed as a port city centered around Kobe.||https://www.pref.hyogo.lg.jp/
|34.68528|135.83278|Nara Prefecture|A city preserving ancient capital culture, including Todai-ji and Horyu-ji.||https://www.pref.nara.jp/
|34.22611|135.16750|Wakayama Prefecture|Characterized by abundant nature covering the Kii Peninsula.||https://www.pref.wakayama.lg.jp/
|35.50361|134.23833|Tottori Prefecture|Home to the Tottori Sand Dunes, the least populated prefecture in Japan.||https://www.pref.tottori.lg.jp/
|35.47222|133.05056|Shimane Prefecture|Famous as the birthplace of mythology, including Izumo Taisha Shrine.||https://www.pref.shimane.lg.jp/
|34.66167|133.93500|Okayama Prefecture|Known for the Momotaro legend and its fruits.||https://www.pref.okayama.lg.jp/
|34.39639|132.45944|Hiroshima Prefecture|Home to UNESCO World Heritage Sites like the Atomic Bomb Dome and Itsukushima Shrine.||https://www.pref.hiroshima.lg.jp/
|34.18611|131.47028|Yamaguchi Prefecture|Located at the westernmost tip of Honshu, famous for fugu (pufferfish) cuisine.||https://www.pref.yamaguchi.lg.jp/
|34.06583|134.55944|Tokushima Prefecture|Famous for Awa Odori dance, considered the gateway to Shikoku.||https://www.pref.tokushima.lg.jp/
|34.34028|134.04333|Kagawa Prefecture|Known as the "Udon Prefecture," the smallest prefecture in Japan.||https://www.pref.kagawa.lg.jp/
|33.84167|132.76611|Ehime Prefecture|Famous for historic hot springs like Dogo Onsen.||https://www.pref.ehime.jp/
|33.55972|133.53111|Kochi Prefecture|Associated with Sakamoto Ryoma, a prefecture rich in nature.||https://www.pref.kochi.lg.jp/
|33.60639|130.41806|Fukuoka Prefecture|A city known for Hakata ramen and yatai (street food stalls) culture.||https://www.pref.fukuoka.lg.jp/
|33.24944|130.29889|Saga Prefecture|Famous for Arita porcelain and Ureshino Onsen.||https://www.pref.saga.lg.jp/
|32.75028|129.87778|Nagasaki Prefecture|A port city with strong influences from foreign cultures.||https://www.pref.nagasaki.lg.jp/
|32.78972|130.74167|Kumamoto Prefecture|Symbolized by Kumamoto Castle and Mount Aso.||https://www.pref.kumamoto.jp/
|33.23806|131.61250|Oita Prefecture|Rich in hot spring resorts such as Beppu and Yufuin.||https://www.pref.oita.lg.jp/
|31.91111|131.42389|Miyazaki Prefecture|A tropical-feeling region famous for mangoes.||https://www.pref.miyazaki.lg.jp/
|31.56028|130.55806|Kagoshima Prefecture|A picturesque prefecture overlooking Sakurajima volcano.||https://www.pref.kagoshima.jp/
|26.21250|127.68111|Okinawa Prefecture|A tropical paradise with a unique culture and beautiful seas.||https://www.pref.okinawa.jp/
23 wards of Tokyo
|35.6938|139.7530|Chiyoda Ward|Home to the Imperial Palace and the National Diet Building, it is the political center of Japan.||https://www.city.chiyoda.lg.jp/
|35.6704|139.7720|Chuo Ward|A commercial hub with areas like Ginza and Nihonbashi, where history and modernity blend.||https://www.city.chuo.lg.jp/
|35.6581|139.7516|Minato Ward|Home to Tokyo Tower and upscale residential areas, it also hosts many international corporations.||https://www.city.minato.tokyo.jp/
|35.6938|139.7036|Shinjuku Ward|Known for the bustling area around Shinjuku Station and its skyscraper district, it is a multicultural hub.||https://www.city.shinjuku.lg.jp/
|35.7081|139.7528|Bunkyo Ward|A district rich in education and greenery, home to the University of Tokyo and other institutions.||https://www.city.bunkyo.lg.jp/
|35.7123|139.7760|Taito Ward|An area where traditional culture and downtown charm remain, including Ueno and Asakusa.||https://www.city.taito.lg.jp/
|35.7100|139.8016|Sumida Ward|Home to Tokyo Skytree, blending traditional crafts with modern culture.||https://www.city.sumida.lg.jp/
|35.6735|139.8174|Koto Ward|A lively area with ongoing waterfront development, featuring Toyosu Market and Odaiba.||https://www.city.koto.lg.jp/
|35.6090|139.7300|Shinagawa Ward|A highly convenient area where business and residential spaces coexist around Shinagawa Station.||https://www.city.shinagawa.tokyo.jp/
|35.6411|139.6984|Meguro Ward|A stylish residential area lined with trendy cafés and shops.||https://www.city.meguro.tokyo.jp/
|35.5614|139.7160|Ota Ward|Home to Haneda Airport and known for its small and medium-sized industrial enterprises.||https://www.city.ota.tokyo.jp/
|35.6466|139.6533|Setagaya Ward|The most populous ward in Tokyo, featuring expansive residential areas and abundant greenery.||https://www.city.setagaya.lg.jp/
|35.6640|139.6982|Shibuya Ward|A hub of youth culture and home to many IT companies, leading the latest trends.||https://www.city.shibuya.tokyo.jp/
|35.7074|139.6658|Nakano Ward|Known as a sanctuary for subcultures, where diverse cultures coexist.||https://www.city.tokyo-nakano.lg.jp/
|35.6995|139.6368|Suginami Ward|A quiet residential area also famous for hosting many anime production companies.||https://www.city.suginami.tokyo.jp/
|35.7285|139.7107|Toshima Ward|Centered around Ikebukuro, this area has many commercial facilities and a strong international presence.||https://www.city.toshima.lg.jp/
|35.7520|139.7337|Kita Ward|A harmonious blend of nature and urban life, featuring many parks and historical buildings.||https://www.city.kita.tokyo.jp/
|35.7365|139.7830|Arakawa Ward|A traditional area preserving the downtown atmosphere and craftsmanship.||https://www.city.arakawa.tokyo.jp/
|35.7512|139.7101|Itabashi Ward|A mixed residential and commercial area with excellent access to central Tokyo.||https://www.city.itabashi.tokyo.jp/
|35.7356|139.6527|Nerima Ward|A residential district with abundant greenery and remaining farmland.||https://www.city.nerima.tokyo.jp/
|35.7750|139.8047|Adachi Ward|A diverse cultural area blending traditional downtown charm with new developments.||https://www.city.adachi.tokyo.jp/
|35.7433|139.8477|Katsushika Ward|An area rich in traditional downtown character, known as the setting for many films and manga.||https://www.city.katsushika.lg.jp/
|35.7064|139.8680|Edogawa Ward|A residential area with many rivers and parks, popular among families.||https://www.city.edogawa.tokyo.jp/
Grid Images
Rendering images in grid structure is also supported. It is useful to show a lot of images which are organized by labels.
The Image list is embedded in HTML as CSV, Markdown, or JSON data. Each record is composed of a label, a list of images, and an optional comment. Images of a record are shown in the same cell.
Read the source code of this page to understand details of how to use it. The following points are essential.
- Loads the JavaScript file mapannotation.js.
- Loads the CSS file mapannotation.css.
- Embeds a CSV/Markdown/JSON image list as an undisplayed element.
- Puts a placeholder block element, where the grid is shown
- Puts a script element to call the renderGridImages function.
Image list in Markdown
|American Village|img/amemura.jpg|Center of young culture
|Brompton|img/bro01.jpg,img/bro02.jpg|Parts of the folding bike
|Nagano life|img/nagano01.jpg,img/nagano02.jpg,img/nagano03.jpg,img/nagano04.jpg,img/nagano05.jpg|Burning weeds in the garden
|Night Scenes|img/night01.jpg,img/night02.jpg,img/night03.jpg|Night of Tokyo
|Osaka|img/osaka.jpg|People's kitchen
|Tokyo|img/tokyo.jpg|Shogun's residence
|Cape Sata|img/sata.jpg|South tip of Japan
|Cape Soya|img/souya.jpg|North tip of Japan
|Tokorozawa|img/tokoro01.jpg,img/tokoro02.jpg,img/tokoro03.jpg,img/tokoro04.jpg|Origin of aviation
|Wan-ichi|img/wan01.jpg,img/wan02.jpg,img/wan03.jpg|Cycling around Tokyo bay
|Weight measurement|img/weight01.jpg,img/weight02.jpg|Checking the front/rear weight ratio
|Daily life 1|img/misc01.jpg,img/misc02.jpg
|Daily life 2|img/misc03.jpg,img/misc05.jpg,img/misc06.jpg
|Daily life 3|img/misc07.jpg,img/misc08.jpg,img/misc09.jpg,img/misc10.jpg
|Daily life 4|img/misc11.jpg
|Daily life 5|img/misc12.jpg,img/misc13.jpg
Image list in JSON