腾讯地图打开地图选取位置 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 ...
随机推荐
- C# StreamReader.ReadLine统计行数的问题
要实现一个功能: 从 lua 文件中提取字符串放到 excel 中,再将 excel 给海外同事,翻译完成后,用翻译的文本替换相应中文. 整个功能并不复杂,要点有二点: 1.提取字符串,一行中文如&q ...
- ASP.NET Core 中的文件上传
ASP.NET Core上传文件 ASP.NET Core使用IFormFile来读取上传的文件内容,然后将数据写入到磁盘或其它存储空间. 添加FileUpload模型,用来接收上传的文件内容. pu ...
- 微信小程序生成指定页面小程序码海报图片分享思路总结
本博客主要说下思路,具体代码不贴 1.考虑到组件复用,所以我把它做成一个自定义的组件 <my-poster id="getPoster" avater="{{ima ...
- jquery-网站收藏
jquery跑马灯:http://www.dowebok.com/demo/188/index3.html
- Spring 拦截器postHandle无法修改Response的原因
如果controller跳转至页面,postHandle是没问题的. 如果@ResponseBody注释 或者返回 ResponseEntity,在postHandle拦截器中修改请求头,是无效的. ...
- angualrjs 配置超时时间
timeout 1 本想通过$httpProvider的defaults属性配置timeout时间, defaults中没有这个属性. https://docs.angularjs.org/api/n ...
- go test 测试用例那些事
go test命令,相信大家都不陌生,常见的情况会使用这个命令做单测试.基准测试和http测试.go test还是有很多flag 可以帮助我们做更多的分析,比如测试覆盖率,cpu分析,内存分析,也有很 ...
- myBase7 激活方法
一.引言: 之前使用过一段时间的myBase,那时候发现还不太美观,所以弃用了一段时间,最近看到有myBase7出来,使用了一下感觉还可以,但是只能试用一个月,不过还好找到了破解的方法. 二.破解步骤 ...
- v2ray和ss的安装资料整理
v2ray: 1. https://yuan.ga/v2ray-complete-tutorial/ 2. https://toutyrater.github.io/ 推荐使用:v2ray,会比ss快 ...
- 我的IT之路这样走过
一.我的IT之路这样走过: 1.大一上学期.我们学校是用C语言做启蒙语言的:虽然我学的相当不错,但是我发现一个问题:用C语言做软件那么它的交付周期比较长. 对于我这种无产阶级来说最关键的是解眼下的粮食 ...