https://lbs.qq.com/tool/component-picker.html

withMap

import React, { Component } from "react";
export default function withMap() {
return function(Target) {
return class WithMap extends Component {
state = {
open: false,
cb: null,
}; componentDidMount() {
const _this = this;
window.addEventListener("message", this.handleMessage, false);
}
componentWillUnmount() {
window.removeEventListener("message", this.handleMessage);
}
handleMessage = event => {
var loc = event.data;
if (loc && loc.module == "locationPicker") {
this.handleToogleOpen(false)(loc);
}
};
handleToogleOpen = (is, cb) => loc => {
this.setState(prevState => ({
open: is,
cb: !!cb ? cb : prevState.cb,
})); const { cb: scb } = this.state;
if (loc && scb) {
scb(loc);
}
};
render() {
return (
<>
{this.state.open && (
<iframe
id="mapPage"
style={{
width: "100%",
height: "100vh",
zIndex: "1200",
position: "fixed",
top: "0",
left: "0",
right: "0",
}}
frameBorder="0"
src={`https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=VT4BZ-42ZWX-EZL43-76VKV-OJXIQ-MIFLF&referer=myapp`}
/>
)} <Target {...this.props} handleToogleOpen={this.handleToogleOpen} />
</>
);
}
};
};
}

使用

@withMap() // 注入即可
@inject(MAINTENANCESTORE)
@observer
class ApplyForMaintenance extends Component {
render() {
const { maintenanceStore, handleToogleOpen } = this.props; const getAddress = handleToogleOpen(true, loc => {
l(loc);
maintenanceStore.AFM.address = loc.poiaddress;
});
return (
<TextField
required
fullWidth
label="地址"
onFocus={getAddress}
value={maintenanceStore.AFM.address}
/>
);
}
}

腾讯地图打开地图选取位置 withMap的更多相关文章

  1. openlayers模仿google地图--地图版权随鹰眼关闭打开而改变位置

    额..题目有点长......今天有个群友问我.想实现google地图地图版权随鹰眼关闭状态改变位置的功能.就是这种<ignore_js_op> 打开鹰眼时  地图版权也随着鹰眼位置改变而改 ...

  2. ArcGIS API for Silverlight 实现修改地图上的工程点位置

    原文:ArcGIS API for Silverlight 实现修改地图上的工程点位置 #region 处理工程点点击编辑相关事件 public Graphic editgraphics = null ...

  3. 打开地图文件和shape文件代码加载Mxd文档

    代码加载Mxd文档 用代码添加Mxd文档,用到AxMapControl.LoadMxFile(sFilePath),我们只要将Mxd文档的路径传给这个方法即可 /// <summary>  ...

  4. HTML5调用百度地图API获取当前位置并直接导航目的地的方法

    <!DOCTYPE html> <html lang="zh-cmn-Hans">     <meta charset="UTF-8&quo ...

  5. 百度地图API定位+显示位置

    1. 先在需要嵌入地图的页面引入map.js <script src="http://api.map.baidu.com/api?v=2.0&ak=你的秘钥"> ...

  6. [Xcode 实际操作]八、网络与多线程-(6)使用UIApplication对象打开地图

    目录:[Swift]Xcode实际操作 本文将演示如何使用应用程序单例对象,打开地图的功能. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKi ...

  7. HTML5页面直接调用百度地图API,获取当前位置,直接导航目的地

    <!DOCTYPE html> <html lang="zh-cmn-Hans"> <meta charset="UTF-8"&g ...

  8. 网页百度地图api,支持位置偏移

    网页百度地图api,支持位置偏移 需加载 jq <style type="text/css"> #allmap {width:100%; height:100%; bo ...

  9. android 3.0+百度地图api地图如何移动到指定的经纬度处

    由于百度地图api,2.0+和3.0+的改动比较大,api基本上被全换过了,有些同学可能2.0+的api使用的非常熟悉,但是更新到3.0+时,却会遇到一些小麻烦(由于api变了,你就需要重新学习它的a ...

随机推荐

  1. java springboot2 jquery 抽奖项目源码

    java+springboot2+jquery+jdk8   实现的多种抽奖效果! 体验抽奖地址: http://47.98.175.6:8091/ 赞助获得源码!!!

  2. Idea checkstyle插件的使用

    File->Setting 选择Plugins,查询是否已经安装了checkstyle,如果没有安装,可以点击下面的“Browse repositories...”按钮 查询到checkstyl ...

  3. Eclipse中jsp和html格式化自动排版问题

    删除inline Elements 中所有的元素 http://m.codes51.com/article/detail_197472.html

  4. TCP 粘包问题浅析及其解决方案

    最近一直在做中间件相关的东西,所以接触到的各种协议比较多,总的来说有TCP,UDP,HTTP等各种网络传输协议,因此楼主想先从协议最基本的TCP粘包问题搞起,把计算机网络这部分基础夯实一下. TCP协 ...

  5. tp5.1的安装与运行流程

    今天安装tp5.1的时候出现问题,我这里使用的是将tp直接解压缩后放在项目里面,结果提示下面的错误:Warning: require(D:\workspace\zhiyuedu\vendor/topt ...

  6. java logAspect

    @Around("execution(* com.iotx.cep.biz.rpc.impl.*.*(..)) " + "&& !execution(* ...

  7. The best manual of how to use "The easiest Xdebug" addon for Firefox

    Installation notes 0. Install the best Firefox add-on for remote debugging The easiest Xdebug. I'm n ...

  8. 和李洪强一起学设计01 PS第一天

    和李洪强一起学设计01 PS第一天

  9. [HDFS Manual] CH7 ViewFS Guide

    ViewFS Guide ViewFS Guide 1 介绍 2. The Old World(Prior to Federation) 2.1单个Namenode Clusters 2.2 路径使用 ...

  10. dockerd启动配置_修改IP和systemd管理

    docker采用CS架构,dockerd是管理后台进程,默认的配置文件为/etc/docker/daemon.json(--config-file可以指定非默认位置). 一个完整的daemon.jso ...