Skip to content

Instantly share code, notes, and snippets.

@cuter44
Created March 2, 2014 15:04
Show Gist options
  • Select an option

  • Save cuter44/9307843 to your computer and use it in GitHub Desktop.

Select an option

Save cuter44/9307843 to your computer and use it in GitHub Desktop.
附着在百度经纬度拾取工具的增强, 将经纬度转换成 geohash.
/** user-script baidu map Lat/Long -> geohash.org adapter
* attach to http://api.map.baidu.com/lbsapi/getpoint/index.html
* for non-IE
*/
function toGeohash()
{
var loc = document.getElementById("pointInput").value.split(",");
var body = document.getElementsByTagName("body")[0];
var oldf = document.getElementById("geohash");
oldf.src = "http://geohash.org/?q="+loc[1]+","+loc[0]+"&format=url&redirect=0";
}
function attach()
{
document.getElementById("MapHolder").addEventListener("click", toGeohash, false);
var f = document.createElement("iframe");
f.id = "geohash";
pos = document.getElementById("pointInput");
pos.parentNode.insertBefore(f, pos);
f.height = 32;
}
if (location.href.match("http://api.map.baidu.com/lbsapi/getpoint/index.html").length == 1)
{
setTimeout("attach()", 10000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment