当前位置: 首页 > wzjs >正文

专业商城网站建设多少钱centos支持wordpress

专业商城网站建设多少钱,centos支持wordpress,好看 大气的网站,19年做哪个网站致富开发准备 上一节我们实现了地图的简单展示,这一节我们要实现的内容是,根据展示的地图,实现当前定位功能,当前位置的poi地址功能,以及列表的展示,给地图添加标记,展示自己的当前定位 功能分析 要…

开发准备
上一节我们实现了地图的简单展示,这一节我们要实现的内容是,根据展示的地图,实现当前定位功能,当前位置的poi地址功能,以及列表的展示,给地图添加标记,展示自己的当前定位

功能分析
要想实现这些功能,首先我们需要在地图加载之前获取当前的经纬度,根据经纬度查询附近的poi地址,然后我们获取这些poi地址展示到列表内,同时我们根据当前位置计算出与列表内地址的直线差距

代码实现
首先我们在展示的地图中添加标记以及视线当前位置的蓝点展示
private marker?: map.Marker;
this.mapController = mapController;
let location = await geoLocationManager.getCurrentLocation();
this.mapController.setMyLocation(location);
this.mapController.setMyLocationEnabled(true);
this.mapController.setMyLocationControlsEnabled(true);

              this.mapEventManager = this.mapController.getEventManager();let markerOptions: mapCommon.MarkerOptions = {position: {latitude: location.latitude,longitude: location.longitude},rotation: 0,visible: true,zIndex: 0,alpha: 1,anchorU: 0.5,anchorV: 1,clickable: true,draggable: true,flat: false};this.marker = await this.mapController.addMarker(markerOptions);this.marker!.setDraggable(false);this.marker!.setMarkerAnchor(1.0, 1.0);

这样我们就已经实现了地图上的标记以及当前位置的展示,我们执行一下代码查看一下效果
在这里插入图片描述
可以看到我们的定位小蓝点以及标记已经成功展示

接下来我们要实现的是获取到当前经纬度一定范围内的poi地址数据
首先定义一个加载完成的标识,以及接受列表
private addressList:Array<site.Site>|null=null

@State infoIsSuccess:boolean=false
然后根据当前的经纬度进行数据的请求
let params: site.NearbySearchParams = {
location: {
latitude: location.latitude,
longitude: location.longitude
},
radius: 5000,
poiTypes: [“EATING_DRINKING”,“SHOPPING”,“LEISURE”],
language: “ch”,
pageIndex: 1,
pageSize: 10
};
const result = await site.nearbySearch(params);
this.addressList=result.sites!
if (result.sites!.length>0) {
this.infoIsSuccess=true
}else {
this.infoIsSuccess=false
}

在这里插入图片描述
通过打断点可以看到我们已经获取到了数据,这时候只需要使用我们定义好的变量接收数据,然后展示到列表上

List(){
ForEach(this.addressList,(item:site.Site,index:number)=>{
ListItem(){
Column(){
Column({space:10}){
Text(item.name)
.fontColor(Color.Black)
.fontSize(16)
.fontWeight(FontWeight.Bold)
Row(){
Text(this.calculateDistance(item.location?.latitude,item.location?.longitude,this.location?.latitude,this.location?.longitude).toFixed(2)+“公里”)
.fontSize(14)
.fontColor(Color.Gray)
Text(" | ")
.fontSize(14)
.fontColor(Color.Gray)

                  Text(item.formatAddress).fontColor(Color.Gray).fontSize(14).textOverflow({ overflow: TextOverflow.Clip }).maxLines(1)}.width('100%').justifyContent(FlexAlign.Start)}.alignItems(HorizontalAlign.Start).padding(10).justifyContent(FlexAlign.Center)Divider().width('100%').height(0.8).color("#e6e6e6")}.onClick(()=>{showToast(JSON.stringify(item))})}})}.layoutWeight(1).backgroundColor(Color.White)

这里我们计算距离,截取最后两位即可
toRadians(degree: number): number {
return degree * Math.PI / 180;
}

calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number {
const R = 6371; // 地球平均半径,单位为公里
const dLat = this.toRadians(lat2 - lat1);
const dLon = this.toRadians(lon2 - lon1);

const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(this.toRadians(lat1)) * Math.cos(this.toRadians(lat2)) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);

const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
const distance = R * c;

return distance;
}

到这里我们的数据展示就成功了,我们执行一下代码看一下效果
在这里插入图片描述
可以看到我们的数据已经成功的展示


文章转载自:

http://eEKbPcwK.nfmLt.cn
http://rGeBlwg8.nfmLt.cn
http://uqckV1Lb.nfmLt.cn
http://a81TbKfr.nfmLt.cn
http://5hJ7NGs0.nfmLt.cn
http://EHXG5U3j.nfmLt.cn
http://O0u06bQU.nfmLt.cn
http://lbrul7Ol.nfmLt.cn
http://cVD5Ftgn.nfmLt.cn
http://zXhfszOQ.nfmLt.cn
http://I26nJAl2.nfmLt.cn
http://9zmpCWxn.nfmLt.cn
http://vKvEh6yz.nfmLt.cn
http://eCWzLmov.nfmLt.cn
http://E1x6jkmD.nfmLt.cn
http://nBaexJ1I.nfmLt.cn
http://TyjD2Nr4.nfmLt.cn
http://lFspO185.nfmLt.cn
http://pwD7joia.nfmLt.cn
http://9EmUtc2b.nfmLt.cn
http://qPs6NBV6.nfmLt.cn
http://QLkgwSzM.nfmLt.cn
http://MDyEucB7.nfmLt.cn
http://Eh7mgxOX.nfmLt.cn
http://pIfuqfvx.nfmLt.cn
http://8v0CXAqY.nfmLt.cn
http://Skw8o3pi.nfmLt.cn
http://bRlIkUyo.nfmLt.cn
http://jgx4lGFF.nfmLt.cn
http://jlxJy4r8.nfmLt.cn
http://www.dtcms.com/wzjs/678408.html

相关文章:

  • 网站建设规划书河北专门做办公的网站
  • 河南省住房城乡和建设厅网站首页wordpress 指南
  • 网站如何做微信支付链接建设个人网站教程
  • 一点空间网站建设wordpress启动慢
  • 建设网站报价单手机网站 建设
  • 三合一网站什么意思注册深圳公司的好处
  • 西部数码官方网站建设工程教育app
  • 建设网站需要花多少钱国家建设部网站2018年
  • 哪些网站可以做推广阿里云备案个人可以做网站吗
  • 温州电子商务网站建设商城模板网站模板
  • 加猛挣钱免费做网站软件网站开发所需人才
  • 做网站需要哪些成本电子 网站建设申请过程
  • 成都优化网站关键词长沙 建网站
  • 网站推广的图片交换友情链接的好处
  • 网站建设中网站需求分析报告作用禅城区电话黄页
  • 织梦 商城网站海南网络广播电视台开学第一课
  • 绍兴免费自助建站湖南省智慧团建登录入口
  • 长沙网站排名公司哪家好网站建设网页设计公司
  • 荣誉章标志做网站微信小程序开发哪家好
  • 建筑公司网站首页图片绍兴高端网站设计
  • 怎么建立微网站?做网站需要什么框架
  • 凡科网站源码下载风中有朵雨做的云网站观看
  • 一般可以在哪些网站做推广wordpress源码解析
  • 怎么用centos做网站单位网站建设建议对策
  • 做网站能成功吗互联网最赚钱的行业
  • 网站开发api平台windows 安装wordpress
  • 服务好的微网站建设个人软件网站域名
  • dede网站模板替换电脑上如何做网站
  • 网站建设属于淘宝哪种类目php网站建设全程解析
  • 建个人网站赚钱吗济南比较好的网站建设公司