老系统对接
This commit is contained in:
38
webapp/js/convertor.js
Normal file
38
webapp/js/convertor.js
Normal file
@ -0,0 +1,38 @@
|
||||
(function() { // <20>հ<EFBFBD>
|
||||
function load_script(xyUrl, callback) {
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = xyUrl;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>jQuery<72><79>script<70><74><EFBFBD><EFBFBD>
|
||||
script.onload = script.onreadystatechange = function() {
|
||||
if ((!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
|
||||
callback && callback();
|
||||
// Handle memory leak in IE
|
||||
script.onload = script.onreadystatechange = null;
|
||||
if (head && script.parentNode) {
|
||||
head.removeChild(script);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
||||
head.insertBefore(script, head.firstChild);
|
||||
}
|
||||
function translate(point, type, callback) {
|
||||
var callbackName = 'cbk_' + Math.round(Math.random() * 10000); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var xyUrl = "http://api.map.baidu.com/ag/coord/convert?from=" + type
|
||||
+ "&to=4&x=" + point.lng + "&y=" + point.lat
|
||||
+ "&callback=BMap.Convertor." + callbackName;
|
||||
// <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>script<70><74>ǩ
|
||||
load_script(xyUrl);
|
||||
BMap.Convertor[callbackName] = function(xyResult) {
|
||||
delete BMap.Convertor[callbackName]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<D2AA><C9BE><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
var point = new BMap.Point(xyResult.x, xyResult.y);
|
||||
callback && callback(point);
|
||||
}
|
||||
}
|
||||
|
||||
window.BMap = window.BMap || {};
|
||||
BMap.Convertor = {};
|
||||
BMap.Convertor.translate = translate;
|
||||
})();
|
Reference in New Issue
Block a user