当前位置:网站首页>Imitate Baidu API of Baidu map page of a website
Imitate Baidu API of Baidu map page of a website
2022-07-24 05:38:00 【amogogo12】
Map page
The illustration is as follows :
Some in the code CSS and JS The document is useless , Test yourself
The code is as follows :
<!doctype html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<base href="https://dt.sofang.com/" />
<script src="/js2.0/jquery-1.11.0.min.js"></script>
<link rel="stylesheet" type="text/css" href="/layui/css/layui.css" />
<title> Ruihe Jincheng _ Datong Rui and Jincheng Real Estate _ House price trend _ Datong SouFun </title>
<meta name="keywords" content=" Ruihe Jincheng | Datong XinPan , Datong new building , SouFun net , Search room - SouFun net "/>
<meta name="description" content=" SouFun net , Datong new house provides you with details of Rui and Jincheng 、 Rui and Jincheng photo album 、 Ruihe Jincheng house type 、 Ruihe Jincheng price , Datong XinPan , Let you have a more comprehensive understanding of the new real estate , Create the best new house purchase experience for you !"/>
<link rel="stylesheet" href="/css20/list.css?v=1650155485">
<link rel="stylesheet" href="/css20/community/detail.css?v=1650155485">
<link rel="stylesheet" href="/css2.0/articleIndex.css?v=1650155485">
<script src="/js/chart/Chart.js"></script>
<script src="/js2.0/jquery.qrcode.min.js"></script>
<script src="/js/point_interest.js?v=1.5.9"></script>
<script src="/js2.0/userFollow.js?v=1.5.9"></script>
<link rel="stylesheet" href="/css20/component/popup_window.css?v=1.5.9">
<link rel="stylesheet" type="text/css" href="/css20/discount_component.css?t=1650155485" />
<script> var con = '[]'; </script>
</head>
<body>
<div id="map" style="padding-top: 32px;float: left;">
<div class="map" style="position: relative;">
<div class="map-title">
Location perimeter
</div>
<div class="" style="margin-top: 12px;">
Location : North of Xijing street in the urban area Plot on the west side of Yong'an Road
</div>
<div class="" style="height: 50px;">
<ul class="map-ul" style="margin-top: 12px;">
<li class="click curpos"> Property location </li>
<li class="chechData" attr=" transit " title=" The surrounding buses "> transit </li>
<li class="chechData" attr=" metro " title=" Surrounding subway "> metro </li>
<li class="chechData" attr=" education " title=" Peripheral Education "> education </li>
<li class="chechData" attr=" The hospital " title=" Surrounding hospitals "> The hospital </li>
<li class="chechData" attr=" Bank " title=" Peripheral bank "> Bank </li>
<li class="chechData" attr=" shopping " title=" Shopping around "> shopping </li>
<li class="chechData" attr=" Restaurant " title=" Surrounding catering "> Restaurant </li>
<li class="chechData" attr=" Bodybuilding " title=" Peripheral fitness "> Bodybuilding </li>
</ul>
</div>
<div id="container" style="width: 1200px;height: 530px;margin-top: 8px;float: left;"></div>
<div class="assort_nav" style="background-color:white;width: 330px;height: 533px;border: 1px solid rgba(219,222,226,1);position: absolute;right: 0px;top:103px;">
<div id="zk" class="zk"></div>
<h2 id="soukey" style="margin-left:16px;background-color:white;height:57px;width: 298px;border-bottom:1px solid rgba(219,222,226,1);font-size:16px;font-family:MicrosoftYaHei;color:rgba(48,49,51,1);line-height:57px;"></h2>
<div id="r-result" style="height: 478px;overflow-y: auto;"></div>
</div>
</div>
</div>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=Y1kG709UBP4L0ac6SvTjxnm7"></script>
<script type="text/javascript"> $(document).ready(function () {
// Longitude and latitude var longitude = "0"; var latitude = "0"; if ((longitude == 0) && (longitude == 0)) {
longitude = 113.366546; latitude = 40.087993; } var map = new BMap.Map("container"); // Create a map instance var point = new BMap.Point(longitude, latitude); // Create point coordinates map.centerAndZoom(point, 15); map.enableScrollWheelZoom(true); // Default tag function curpos() {
map.clearOverlays(); // Current real estate address var marker2 = new BMap.Marker(point); // Create annotations map.addOverlay(marker2); var opts = {
position: point, // Specifies the geographic location of the text annotation offset: new BMap.Size(-45, -50) // Set text offset } var label = new BMap.Label(" Current property location ", opts); // Create text annotation objects label.setStyle({
color: "red", fontSize: "12px", height: "20px", lineHeight: "20px", fontFamily: " Microsoft YaHei " }); map.addOverlay(label); } // Click around $('.chechData').bind('click', function (e) {
e.stopPropagation(); e.preventDefault(); var data1 = $(this).attr('attr'); var data2 = $(this).text(); chechData(data1, data2); $(this).addClass("click"); $(this).siblings().removeClass("click") }); function chechData(data1, data2) {
$('#soukey').text(data2); $('.periphery_nav').hide(); $('.periphery_build').show(); curpos(); $('.assort_nav').show(); $('soukey').html('<i></i>' + data2); var circle = new BMap.Circle(point, 1000, {
fillColor: "blue", strokeWeight: 1, fillOpacity: 0.3, strokeOpacity: 0.3 }); map.addOverlay(circle); var local = new BMap.LocalSearch(map, {
renderOptions: {
map: map, panel: "r-result", autoViewport: false}, // renderOptions: {map: map}, pageCapacity: 6, onSearchComplete: function (results) {
console.log(results) } }); local.searchNearby(data1, point, 1000); } $('.curpos').click(function (e) {
e.stopPropagation(); e.preventDefault(); var c_name = " Address name "; var c_address = " North side of urban street Plot on the west side of Yong road "; $(this).siblings().removeClass("click"); $(this).addClass("click"); map.clearOverlays(); // Current real estate address var marker2 = new BMap.Marker(point); // Create annotations map.addOverlay(marker2); var opts = {
width: 100, // Information window width height: 70, // Information window height title: " The name of the property :" + c_name, // Message window title offset: new BMap.Size(-5, -20) // Set text offset } var infoWindow = new BMap.InfoWindow(" Address :" + c_address, opts); // Create information window object map.openInfoWindow(infoWindow, point); // Open the message window $('.assort_nav').hide(); }).trigger('click'); }); </script></body>
</html>
The longitude and latitude inside and the text can be used after modification . If it helps you, please like . Please forgive me if there is any mistake
边栏推荐
- Promise_ Async and await
- Function_ This keyword
- 在本地怎么使用phpstudy搭建WordPress网站
- 新建 umi 项目,Error: Rendered more hooks 或者 Rendered fewer hooks
- 面向 对象
- 公链Sui Layer1网络
- mysqldump 导出中文乱码
- Geoserver REST API功能解析
- The repetition detection function of PHP multi line text content and count the number of repetitions
- Canvas - rotate
猜你喜欢

vulnhub-SolidState: 1靶机渗透测试

canvas - 旋转

Variables and constants in C language

node连接mysql,使用navicat可视化

Function analysis of GeoServer rest API

Canvas - rotate

网页播放rtsp视频流

公司女同事深夜11点让我去她住处修电脑,原来是C盘爆红,看我一招搞定女同事....的电脑

首届波卡黑客松项目「Manta Network」的进击之路

Station B video comment crawling - take the blade of ghost destruction as an example (and store it in CSV)
随机推荐
Canvas Bezier Bezier curve
开发技术指南 | 最全 Substrate 与 Polkadot 技术文档、教程、课程
Keywords_ 02break and continue
Geoserver自动化上传Shapefile
How to export Excel files with php+mysql
There are three ways to create in Polkadot - parallel chain, parallel thread, and smart contract
Draw a moving teapot on the screen. The teapot first moves slowly towards the screen, becoming smaller and smaller, becoming more and more blurred; Then it grows bigger and clearer, and keeps repeatin
Analysis of logic development principle of quantitative contract clip arbitrage robot system
PoS机制随机性解读,波卡的随机性原理如何运作?
The repetition detection function of PHP multi line text content and count the number of repetitions
微信小程序map的使用
稀缺性之于Web3:如何成为去中心化世界的胜利者
How to use phpstudy to build WordPress website locally
flex布局
Canvas - rotate
Analysis of Dao liquidity dual currency pledge mining development principle
mysql查询手机号码后四位,前几位怎么写?
Vulnhub solidstate: 1 target penetration test
Geoserver REST API功能解析
【奖励发放】OneOS专区首届征文活动评奖结果公布