Baidu map API and Baidu map API
Baidu API interface: http://developer.baidu.com/map/jsdemo.htm#a1_1
Detailed explanation of Baidu map API map annotation: http://www.cnblogs.com/jz1108/archive/2011/09/15/2152122.html
[Baidu map API] self-acquisition of regional latitude and longitude tools: http://www.cnblogs.com/milkmap/archive/2012/02/23/2365064.html
<? Phpheader ("Content-Type: text/html; charset = UTF-8"); require_once ("../db_config.php");?> <? Php $ SQL = "SELECT * FROM 'retailersinfotable'"; $ query = mysql_query ($ SQL); $ location = NULL; $ clat = 0; $ clng = 0; $ I = 0; if (mysql_num_rows ($ query) {while ($ row = mysql_fetch_array ($ query) {$ I ++; $ location [] = array ("longpolling" => $ row ["longpolling"], "Latitude" => $ row ["Latitude"], "name" => $ row ["RetailersName"], "kpname" => $ row ["RetailersKP"], "kpphone" => $ row ["RetailersLeaderPhone"], "rid" => $ row ["RID"], "retailersid" => $ row [" RetailersID "],); $ clat + = $ row [" Latitude "]; $ clng + = $ row [" longpolling "] ;}$ clat = $ clat/$ I; // average all vertices to get the initialization positioning point $ clng = $ clng/$ I ;}?> <! DOCTYPE html>
How can I obtain the coordinates after clicking on the Baidu map API?
Tag listening
// Add a tag click listener
Marker. addEventListener ("click", function (e ){
Gc. getLocation (e. point, function (rs ){
ShowLocationInfo (e. point, rs );
});
});
Map. centerAndZoom (point, 15); // you can specify the coordinates of the center and map level.
Map. addOverlay (marker); // Add the tag to the map
How Does Baidu map api draw a straight line between two coordinate points on Baidu map?
Var polyline = new BMap. Polyline ([
New BMap. Point (lng1, lat1) // longitude and latitude of the start Point
New BMap. Point (lng2, lat2) // latitude and longitude of the ending Point
], {StrokeColor: "red", // set the color
StrokeWeight: 3, // width
StrokeOpacity: 0.5}); // transparency
Map. addOverlay (polyline );
Let me give you an address, which is the most basic example. I have been studying it here: developer.baidu.com/map/jsdemo.htm