Google Maps検索ボックスに緯度経度を挿入する
Google Mapsでは周辺検索をするときに、一々自分で位置情報を入力しなければならないので結構面倒です。そこでこれを解消するためのスクリプトを書きました。
bookmarklet:
javascript:(function(){if(document.domain.match(/maps\.google\.co(m|\.jp)/)){var%20o=document.getElementById('l_near');var%20p=document.getElementById('d_d');var%20q=document.getElementById('d_daddr');var%20input=function(){var%20loc=document.getElementById('link').href;if(loc.match(/[\?&]ll=([\d\.\-]+,[\d\.\-]+)/)){this.value=loc.match(/[\?&]ll=([\d\.\-]+,[\d\.\-]+)/)[1];}else%20if(loc.match(/[\?&]near=(.*?)[&$]/)){this.value=decodeURI(loc.match(/[\?&]near=(.*?)[&$]/)[1]);}else%20if(loc.match(/[\?&]q=(.*?)[&$]/)){this.value=decodeURI(loc.match(/[\?&]q=(.*?)[&$]/)[1]);}};o.addEventListener('dblclick',input,false);p.addEventListener('dblclick',input,false);q.addEventListener('dblclick',input,false);}})();
greasemonkeyスクリプト
http://userscripts.org/scripts/source/11284.user.js
検索ボックスをダブルクリックすることによって、現在の緯度経度が挿入されます。地名、施設名で検索し、なおかつ地図の移動がなかった場合は、その検索語が挿入されます。
// ==UserScript== // @name insert location info into Google Maps search box // @namespace http://d.hatena.ne.jp/Koumei_S/ // @description inserts lat/long info into Google Maps by double-clicking at search box. // @include http://maps.google.co.jp/* // @include http://maps.google.com/* // @version 1.1 // ==/UserScript== (function(){ var o=document.getElementById('l_near'); var p=document.getElementById('d_d'); var q=document.getElementById('d_daddr'); var input=function(){ var loc=document.getElementById('link').href; if(loc.match(/[\?&]ll=([\d\.\-]+,[\d\.\-]+)/)){ this.value=loc.match(/[\?&]ll=([\d\.\-]+,[\d\.\-]+)/)[1]; } else if(loc.match(/[\?&]near=(.*?)[&$]/)){ this.value=decodeURI(loc.match(/[\?&]near=(.*?)[&$]/)[1]); } else if(loc.match(/[\?&]q=(.*?)[&$]/)){ this.value=decodeURI(loc.match(/[\?&]q=(.*?)[&$]/)[1]); } }; o.addEventListener('dblclick',input,false); p.addEventListener('dblclick',input,false); q.addEventListener('dblclick',input,false); })();