腾讯地图打开地图选取位置 withMap
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的更多相关文章
- openlayers模仿google地图--地图版权随鹰眼关闭打开而改变位置
额..题目有点长......今天有个群友问我.想实现google地图地图版权随鹰眼关闭状态改变位置的功能.就是这种<ignore_js_op> 打开鹰眼时 地图版权也随着鹰眼位置改变而改 ...
- ArcGIS API for Silverlight 实现修改地图上的工程点位置
原文:ArcGIS API for Silverlight 实现修改地图上的工程点位置 #region 处理工程点点击编辑相关事件 public Graphic editgraphics = null ...
- 打开地图文件和shape文件代码加载Mxd文档
代码加载Mxd文档 用代码添加Mxd文档,用到AxMapControl.LoadMxFile(sFilePath),我们只要将Mxd文档的路径传给这个方法即可 /// <summary> ...
- HTML5调用百度地图API获取当前位置并直接导航目的地的方法
<!DOCTYPE html> <html lang="zh-cmn-Hans"> <meta charset="UTF-8&quo ...
- 百度地图API定位+显示位置
1. 先在需要嵌入地图的页面引入map.js <script src="http://api.map.baidu.com/api?v=2.0&ak=你的秘钥"> ...
- [Xcode 实际操作]八、网络与多线程-(6)使用UIApplication对象打开地图
目录:[Swift]Xcode实际操作 本文将演示如何使用应用程序单例对象,打开地图的功能. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKi ...
- HTML5页面直接调用百度地图API,获取当前位置,直接导航目的地
<!DOCTYPE html> <html lang="zh-cmn-Hans"> <meta charset="UTF-8"&g ...
- 网页百度地图api,支持位置偏移
网页百度地图api,支持位置偏移 需加载 jq <style type="text/css"> #allmap {width:100%; height:100%; bo ...
- android 3.0+百度地图api地图如何移动到指定的经纬度处
由于百度地图api,2.0+和3.0+的改动比较大,api基本上被全换过了,有些同学可能2.0+的api使用的非常熟悉,但是更新到3.0+时,却会遇到一些小麻烦(由于api变了,你就需要重新学习它的a ...
随机推荐
- jPlayer获取播放时间
关于jPlayer的用法,可以参考:jPlayer 2.6.0开发者手册 http://www.jplayer.cn/developer-guide.html 视频播放例子: //视频播放 var v ...
- Linux系统复制文件/文件夹到远程服务器
从一个服务器复制文件到另一个服务器,或者从本地到远程复制是 Linux 管理员的日常任务之一. 我觉得不会有人不同意,因为无论在哪里这都是你的日常操作之一.有很多办法都能处理这个任务,我们试着加以概括 ...
- webstorm intelliJ IDEA phpstorm 设置鼠标滚动改变字体大小
control+shift+A功能可以搜索对应功能,把mouse:Change font size(Zoom) ...的按钮打开,然后就可以通过 ctrl+鼠标上下滚动调节字体大小
- 对Faster R-CNN的理解(3)
2.2 边框回归 边框回归使用下面的几个公式: xywh是预测值,带a的是anchor的xywh,带*的是GT Box的xywh,可以看作是anchor经过一定的变换回归到附近的GT Box.
- 为啥百度、网易、小米都用Python?Python的用途是什么?
Python是一门脚本语言.由于能将其他各种编程语言写的模块粘接在一起,也被称作胶水语言.强大的包容性.强悍的功能和应用的广泛性使其受到越来越多的关注,想起一句老话:你若盛开.蝴蝶自来. 假设你感 ...
- C# yield return; yield break;
using System; using System.Collections; namespace YieldDemo { class Program { public static IEnumera ...
- django项目settings.py的基础配置
一个新的django项目初始需要配置settings.py文件: 1. 项目路径配置 新建一个apps文件夹,把所有的项目都放在apps文件夹下,比如apps下有一个message项目,如果不进行此项 ...
- iOS开发下载文件速度计算
当我们写下载界面的时候,需要向用户展示每秒下载多少KB,这个时候就需要计算速度.如下: 我用的是AFNetworking来做下载的,我们拿AFHTTPRequestOperation来举列,AFHTT ...
- JVM:Java常见内存溢出异常分析
转载自:http://www.importnew.com/14604.html Java虚拟机规范规定JVM的内存分为了好几块,比如堆,栈,程序计数器,方法区等,而Hotspot jvm的实现中,将堆 ...
- ICE简单介绍及使用示例
转自:http://blog.csdn.net/zhu2695/article/details/51494664 1.ICE是什么? ICE是ZEROC的开源通信协议产品,它的全称是:The Inte ...