当前位置:网站首页>Baidu map API drawing points and tips
Baidu map API drawing points and tips
2022-06-24 13:58:00 【Liz Liz】
import React, {
Component } from 'react';
import {
message } from 'antd';
import './index.less';
import httpClient, {
RESPONSE_OK } from '../../service/httpClient';
import apis from '../../service/config';
class MapStyle extends Component {
constructor(props) {
super(props);
this.state = {
mapName: ' Address ',
mapContent: ' Magic Castle Balala Wula Wula pineapple mango strawberry Street 2021-04-27 No. Road '
}
}
component() {
this.getInfo();
}
getInfo = async () => {
let res = await httpClient.post(apis.mapInfoGet, {
});
if(res.code === RESPONSE_OK) {
let point = new BMap.Point(res.result.lng, res.result.lat);
this.mapInit(point);
this.openMapInfo(point);
}
}
// Initialize map
mapInit = (point) => {
this.map = new BMap.Map('rescMap', {
enableMapClick: false,
});
this.map.centerAndZoom(
new BMap.Point(point),
15
);
this.map.enableScrollWheelZoom(true); // Enable the scroll wheel to zoom in and out , Default disabled
this.map.setDefaultCursor("url('bird.cur')"); // Set the default mouse pointer style of the map
let marker = new BMap.Marker(point); // Create annotations
this.map.addOverlay(marker);
marker.addEventListener("click", () => {
this.openMapInfo(point);
});
}
openMapInfo = (point) => {
const {
mapName, mapContent } = this.state;
let opts = {
position: point,
width: 25, // Information window width
height: 10, // Information window height
title: mapName // Message window title
}
let infoWindow = new BMap.InfoWindow(mapContent, opts); // Create information window object
this.map.openInfoWindow(infoWindow, point);
}
render() {
return(<div>
<div id="rescMap" className='rdl-map-content'></div>
</div>);
}
}
export default MapStyle;
边栏推荐
- Research and development practice of Kwai real-time data warehouse support system
- js去除字符串空格
- 2022 coal mine gas drainage operation certificate examination questions and simulation examination
- Rasa 3.x 学习系列-非常荣幸成为 Rasa contributors 源码贡献者,和全世界的Rasa源码贡献者共建共享Rasa社区!
- Vulnerability management mistakes that CIOs still make
- 杰理之可能出现有些芯片音乐播放速度快【篇】
- 记录一次Mongotemplate的And和Or的各种套
- pip uninstall all packages except builtin package
- HarmonyOS. two
- 发扬连续作战优良作风 全力以赴确保北江大堤安全
猜你喜欢
MIT-6.824-lab4A-2022(万字讲解-代码构建)
In the era of knowledge economy, it will teach you to do well in knowledge management
Eight major trends in the industrial Internet of things (iiot)
华为 PC 逆势增长,产品力决定一切
【5G NR】5G NR系统架构
Activity生命周期
AntD checkbox,限制选中数量
杰理之串口接收 IO 需要设置数字功能【篇】
SAP Marketing Cloud 功能概述(三)
Rasa 3.x 学习系列-非常荣幸成为 Rasa contributors 源码贡献者,和全世界的Rasa源码贡献者共建共享Rasa社区!
随机推荐
万用表的使用方法
pip uninstall all packages except builtin package
Manuel d'entrevue du gestionnaire de l'analyse des sources
One click to generate University, major and even admission probability. Is it so magical for AI to fill in volunteer cards?
Home office should be more efficient - automated office perfectly improves fishing time | community essay solicitation
Dragon lizard developer said: first time you got an electric shock, so you are such a dragon lizard community| Issue 8
发扬连续作战优良作风 全力以赴确保北江大堤安全
HarmonyOS-3
远程办公之:在家露营办公小工具| 社区征文
[5g NR] 5g NR system architecture
源码解析 Handler 面试宝典
杰理之在所有模式下打开喊话增加 mic 自动 mute【篇】
【sdx62】WCN685X IPA注册失败问题分析及解决方案
redis 数据类型详解
HarmonyOS-3
智源社区周刊#86:Gary Marcus谈大模型研究可借鉴的三个语言学因素;谷歌提出媲美Imgen的文生图模型Parti;OpenAI提出视频预训练模型VPT,可玩MC游戏
How to avoid serious network security accidents?
Can a team do both projects and products?
Jericho After sleep, the system will wake up regularly and continue to run without resetting [chapter]
Docker installation redis