当前位置:网站首页>Teach you how to add custom controls to a map
Teach you how to add custom controls to a map
2022-06-25 20:00:00 【Huawei Developer Forum】
Requirements describe
Developers can add custom controls on the map component that can respond to click events .
Implementation analysis
This example places two control buttons on the map component to zoom in and out of the map display level , Click the control button , Trigger the control click event of the map component , adopt id Identify the clicked control , Then carry out logical processing respectively .
Sample screenshot :

resolvent
The code is as follows :
<template> <div> <map style="width:{{width}}; height:{{height}}" id="map" scale="{{scale}}" controls="{{controls}}" @controltap="controlTap"></map> </div></template><script> import prompt from '@system.prompt' export default { private: { width: '100%', height: '50%', scale: 17, controls: [ { id: 1, position: { right: '15px', bottom: '300px', width: '70px' }, iconPath: '/Common/plus.png' }, { id: 2, position: { right: '15px', bottom: '200px', width: '70px' }, iconPath: '/Common/minus.png' } ] }, controlTap(res) { switch (res.controlId) { case 1: this.scale++ // Because the zoom level of the map has an upper limit , Prevent continuous generation of invalid values this.$element('map').getScale({ success: res => { this.scale = res.scale } }) prompt.showToast({ message: ' Control : Zoom in on the map ' }) break case 2: this.scale-- // Because the zoom level of the map has a lower limit , Prevent continuous generation of invalid values this.$element('map').getScale({ success: res => { this.scale = res.scale } }) prompt.showToast({ message: ' Control : Reduce the map ' }) break default: break } } }</script>map Component reference :
https://developer.huawei.com/consumer/cn/doc/development/quickApp-References/quickapp-component-map
More highlights , Please see the official Huawei Developer Forum →https://developer.huawei.com/consumer/cn/forum/home?ha_source=sanfang
边栏推荐
- Jsonp function encapsulation
- 3、 Hikaricp source code analysis of connection acquisition process III
- PAT B1096
- Profile path and name
- Bloom filter
- JS advanced
- 二、HikariCP獲取連接流程源碼分析二
- Determine whether it is a web page opened on wechat
- Server journey from scratch - Yu Zhongxian integrated version (IP access server, LNMP compilation and installation, Lua environment and socket expansion)
- Using flex to implement the Holy Grail layout is as simple as that
猜你喜欢

Suddenly found that the screen adjustment button can not be used and the brightness can not be adjusted

<C>. Figure guessing game

Google SEO external chain releases 50+ website platform sharing (e6zzseo)

Record Baidu search optimization thinking analysis

Vulnhub range - the planes:venus

JS asynchronism (I. asynchronous concept, basic use of web worker)

Single chip microcomputer line selection method to store impression (address range) method + Example

What are Baidu collection skills? 2022 Baidu article collection skills

Use of serialize() and serializearray() methods for form data serialization

PHP synchronizes website content to hundreds of websites to improve SEO ranking
随机推荐
PostgreSQL change table owner
Is it safe to open an account with flush?
Is it safe to open a new bond account
Yum command
PAT B1059
Use of serialize() and serializearray() methods for form data serialization
2.3 partial sum of square and reciprocal sequences
Process of vacuum and vacuum full
Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information
Jsonp function encapsulation
Principles of MySQL clustered index and non clustered index
Case: count the most characters and times
Life cycle function of composite API
Analyse du code source du processus d'acquisition et de connexion hikaricp II
ECS 7-day practical training camp (Advanced route) -- day03 -- ecs+slb load balancing practice
Ali visual AI training camp -day03- construction of electronic photo album (face and expression recognition)
Dependency injection in PHP reflection implementation framework
Jsonp non homologous interaction (click trigger)
Browser performance optimization (19)
<C>. array