Google Maps / Ditu switcher bookmarklet
Google Maps, Javascript July 18th, 2007
Ditu.google.com is the Chinese version of Google Maps, Google maps is a great product however in China, there is no detailed map, all we can play around is the satellite images. Google China released Ditu which is the answer, however due to China’s local law google is not allowed to put it together with the satellite image.
I wrote a small bookmarklet to allow you siwtch between Ditu and Google Maps automatically, locate to a position either in Google Maps or Ditu, click the bookmarlet, the page will automatically switch to the same location of the other site.
Drag this link to your Firefox address bar:
Ditu/Maps Switcher
The source code is here:
<a href="javascript:url = ''+document.getElementById('link'); if ((url.search(/http:\/\/maps.goog/i) ==-1) && (url.search(/http:\/\/ditu.goog/i)==-1)) { alert('Do not click this links, drag it too your address bar. \nThis bookmarklet only works on maps.google.com or ditu.google.com.\nCheck update on http://dev.robertmao.com/category/google-maps for latest updates or other google maps hack.'); } else { if (url.search(/ditu/i)==-1) { url=url.replace(/maps./i, 'ditu.'); } else {url=url.replace(/ditu./i, 'maps.'); if (url.search(/&t=k/i) ==-1) url += '&t=k'; } window.location=url;}">Ditu/Maps Switcher</a>
You can also copy the part “javascript:….url;}” and paste in your address input box and hit return to make a switch. However I think drag the link as a bookbarklet is a better idea.
I didn’t test under IE, so not sure if it work. Try at your own risk.
I am thinking writing a hack to overlap the image files of Ditu and Google Maps, it gonna be cooler, but this is still just an idea. One issue is, during I play arround, I found Ditu’s position is not exactly match the satellites images, maybe it’s also because google need to follow some local policy.
Popularity: 14% [?]
About
[…] 只是编来玩和自用的,没有测试在Firefox以外的浏览器上是否正确。需要了解更多的在这里(英文的)。 […]
[…] 只是编来玩和自用的,没有测试在Firefox以外的浏览器上是否正确。需要了解更多的在这里(英文的)。 […]
[…] 只是编来玩和自用的,没有测试在Firefox以外的浏览器上是否正确。需要了解更多的在这里(英文的) […]
[…] days ago I wrote a small bookmarklet to switch between Google Maps and Google Ditu, now I have a simple maskup which add google ditu as a customized layer in Google […]