Wednesday, April 9, 2014

How to map coordinates into Google Baidu map


Recently made a map application, the mobile terminal using Baidu map. But backstage pass over the coordinates are the coordinates of Google positioning (Web version because before this application). Search the Internet a lot, there is no right answer, it is hereby posting help. .
You crossing the gods, Manga ~ ~ ~
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
The same planet, longitude and latitude are the same, no conversion.
Reply:
But the same location Google and Baidu locate the latitude and longitude positioning is not the same. What seems to be because the offset calculation it
This tool is provided as Baidu http://dev.baidu.com/wiki/static/map/API/examples/?v=1.3&0_6 # 0 & 6

But seemingly no conversion on Android, it is more a headache.
Reply:
 
/ / 2011-7-25
(Function () {/ /?
function load_script (xyUrl, callback) {
var head = document.getElementsByTagName ('head') [0];
var script = document.createElement ('script');
script.type = 'text / javascript';
script.src = xyUrl;
/ /? T palpitation Query Luo cript tamarisk Shui
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); / /: small-minded

var xyUrl = "http://api.map.baidu.com/ag/coord/convert?from =" + type + "& to = 4 & x =" + point.lng + "& y =" + point.lat + "& callback = BMap.Convertor." + callbackName;
/ /?? Yi cript? ~
load_script (xyUrl);
BMap.Convertor [callbackName] = function (xyResult) {
delete BMap.Convertor [callbackName];? / / (d9 small-minded
var point = new BMap.Point (xyResult.x, xyResult.y);
callback && callback (point);
}
}

window.BMap = window.BMap | | {};
BMap.Convertor = {};
BMap.Convertor.translate = translate;
}) ();



This is your web page corresponding to the js part, the main use of the translate function above, the request is sent to the conversion, reference may be to write their own, right?
Reply:
It should also be coupled with these words:

 

var ggPoint = new BMap.Point (x, y);
BMap.Convertor.translate (ggPoint, 2, translateCallback);



As defined BMap.Point not yet found say ...

Reply:
references, 4th Floor reply:
should also add these words:

JScript code


var ggPoint = new BMap.Point (x, y);
BMap.Convertor.translate (ggPoint, 2, translateCallback);




As defined BMap.Point not yet found say ...

Thank you very much ha. I was on the Android platform, but the most important part, is to send a request to the Url.
Reply:
Hey, there are actually a very simple method on Android, but Baidu Api Lane did not write. . . .
Reply:
How to solve ah, seeking to explain ah. . .
Reply:
I have recently encountered this problem, how to solve the landlord is it?
Reply:
Is not get encrypted coordinate transformation from http://api.map.baidu.com/ag/coord/convert this link and then what, I really do not know the landlord where so high sense of accomplishment by Base64 decoding. Going to tell others how strongly despise refused ...
Reply:
reference to the 9th floor MrRabbit reply:
not that get converted from http://api.map.baidu.com/ag/coord/convert this link Encryption coordinate Then what, I really do not know the landlord where so high sense of accomplishment by Base64 decoding. refused to tell someone else how strong contempt ...


Haha, that is, he does not write, I write it;

Other coordinate systems will be converted to Baidu coordinate system. Interface sample as follows:
http://api.map.baidu.com/ag/coord/convert?from=2&to=4&x=116.254615&y=29.814476
Parameter Description:
x / y: latitude and longitude coordinates
from / to: determine the effect of the conversion, the number of days filled with specific parameters are as follows:
from = 2 means that Google
from = 0 indicates gps
to = 4 means that Baidu
Reply:
The reply was deleted administrator at 2013-03-11 15:15:26

Reply:
Return back to the {"error": 0, "x": "MTE2LjI2MTA5OTEyMjE =", "y": "MjkuODIwNTYwODc0ODQ2"}
Such json, using base64 possible solutions, but the results obtained large deviation,
How to solve it in this regard?
Because I do not want interspersed js in development, so I hope there are other ways to solve ~ enlighten people look up to
Reply:
Baidu and Google's latitude and longitude coordinates of the order is reversed. . .

No comments:

Post a Comment