Home  >  Article  >  Web Front-end  >  js calls Baidu map api and adds points and annotations on the map_javascript skills

js calls Baidu map api and adds points and annotations on the map_javascript skills

PHP中文网
PHP中文网Original
2017-03-28 16:14:232539browse

I am going to make a webpage recently. The specific content is: there is a title at the top, divided into two parts at the bottom, and a map on the left. And there are two points on the map. Clicking on the two points will bring up corresponding prompt information and display the latest two data information in the database. On the right are some text descriptions. I just started learning and I’m not doing very well

The overall effect is as follows:

js calls Baidu map api and adds points and annotations on the map_javascript skills

First create a new map.php file with the following code

Copy code The code is as follows:



/*
Create a connection to the database
*/
$conn=mysql_connect("","" ,"") or die("can not connect to server");
mysql_select_db("hdm0410292_db",$conn);
mysql_query("set names utf8");
//Select two vehicles The latest data inserted into the car, and the two statements are stored in the array
$sql0="select * from car_info where carID='20140508'order by id desc limit 1";
$sql1="select * from car_info where carID= '20140510' order by id desc limit 1";
$sql=array($sql0,$sql1);
?>




Internet of Vehicles Information Display




< ;/p>




The map.php file mainly displays two pieces of information in the database and displays the two pieces of information at the corresponding locations on the map.

Then create title.php, this is very simple, just display a title

Copy the code The code is as follows:







Information display



Information display





Then create the detailed information description module info.php

Copy the code The code is as follows:




$conn=mysql_connect("","","") or die("can not connect to server");
mysql_select_db("",$ conn);
mysql_query("set names utf8");
$sql0="select * from car_info where carID='20140508'order by id desc limit 1";
$sql1="select * from car_info where carID= '20140510' order by id desc limit 1";
$sql=array($sql0,$sql1);

function htmtocode($content){
$content=str_replace ("n", "
", str_replace(" ", " ", $content));
return $content;
}
?>




Information display




Information Display< /H1>
$query=mysql_query($value);
$row=mysql_fetch_array($query);
?>

car Details




CAR ID:

Longitude:

Latitude: < br>
Speed: Km/h

Acceleration:

Direction:

Oil volume:

Address: < ;?php echo $row[street]?>

Time:

< /body>


Finally, write a vanet.php file, which mainly calls the first three files

Copy code The code is as follows:








Information display










Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn