react 高德图的使用定位到指定的经纬度react-amap模块的使用!!

需要定位的地方的经纬度获取: 

https://lbs.amap.com/console/show/picker

import React from 'react';
import { connect } from 'dva';
import Map from 'react-amap/lib/map';//需要安装的模块
import Marker from 'react-amap/lib/marker';//需要安装的模块
import Information from "~/components/Information/Information";
import styles from "./Contact.less";
//import styles from './index.less';

@connect(state => ({
  global: state.global,
}))
export default class Contact extends React.Component {

  constructor(props){
    super(props);
    this.ajaxFlag = true;
    this.state = {

    }
  }

  componentDidMount(){

  }

  render(){
    //116.429828,39.84504
    const position = { longitude: 116.429828, latitude: 39.84504}//需要定位的经纬度
   //zoom 需要放大的倍数
  //宋家庄交通枢纽站是指定的添加的小气泡
    return(
      <div>
        <Information>
          {/*联系我们*/}
          <p className={styles.title}>联系我们丨Contact us</p>
          {/*地图显示*/}
          <div className={styles.mapImg}>
            <Map plugins={['ToolBar']} zoom={18} center={position}>
              <Marker position={position} ><div className={styles.tag}>宋家庄交通枢纽站</div></Marker>
            </Map>
          </div>
          <div className={styles.clean}></div>
          {/*调整地图的小气泡*/}
          {/*<div className={styles.clean}></div>*/}
          {/*<div className={styles.tag}>宋家庄交通枢纽站</div>*/}
        </Information>

      </div>
    )
  }

}

 请看效果图:

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值