Git Product home page Git Product logo

baiduwgs84's Introduction

Baidu WGS84

On the Internet there are lots of publications concerning Baidu wrong coordinates. That misunderstanding happens because a lot of different exsisting positioning systems may have different coordinates. Here is the script, which transforms Google coordinates to Baidu coordinates.

Example, how to use it:

<html>
	<head>
		<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
		<script type="text/javascript" src="geoConverter.js"></script>
	</head>
	<body>
		<div style="width:100%;height:100%;" id="container"></div>
	</body>
</html>

<script type="text/javascript">
	var map = new BMap.Map("container");
	map.addControl(new BMap.NavigationControl());
	map.addControl(new BMap.MapTypeControl({mapTypes : [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP]}));
	map.enableScrollWheelZoom();

    var tmp = convertWGS84toBD09(22.234327, 113.58507);
    var point = new BMap.Point(tmp.lon, tmp.lat);
	var marker = new BMap.Marker(point, {});
	map.addOverlay(marker);
	map.centerAndZoom(point, 16);
</script>

Here you can check, that the result is correct:

https://maps.google.ru/maps?q=22.234327+113.58507&t=h&z=16

Or try any other map, that uses WGS84:

http://toolserver.org/~geohack/geohack.php?language=ru&params=22.234327_N_113.58507_E_

Important notes:

If you want to match a certain point on Google satelite view to a map view, use convertWGS84toGCJ02 function.

Different versions of Baidu maps API have small differences in algorithms. Those script is for v1.3.

License:

MIT (free for all, no warranty or guarantee)

baiduwgs84's People

Contributors

kamapcuc avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.