当前位置:网站首页>uniapp | Problems with the use of the official map component
uniapp | Problems with the use of the official map component
2022-08-02 04:02:00 【dumb papa】
1. Selection of map SDK
Before using uniapp to develop map functions, bloggers used Baidu Maps SDK to develop web map functions.In the initial development, I hope to be able to use the SDK of Baidu Maps, but there is a big difference between uniapp and web-side development when accessing the map function. Uniapp provides a map component
Note: When debugging on the real machine, the
2, different page file selection
When using uniapp for APP development, you can choose the vue page (suffixed with .vue) and the nvue page (suffixed with .nvue). The difference between the
Recommended to read carefully: Uniapp's map component introduction
Use vue page development (there is a hierarchy problem)
If you want to add other content to the map component: you can use the marker, control in the map component and the
Note: The
Use nvue page development (no hierarchy problem)
To use nvue page, you need to configure nvue page and vue page in pages.json, there is no hierarchy problem in nvue page, you can nest tags at will in the map component, but the nvue page refers to the weex framework, which only supports flex layout in layout, does not support adding shadows, and supports limited tags and CSS. does not support CSS such as SCSSProcessorCorrect here, nvue page supports scss
Recommended to read carefully: Uniapp's nvue framework tutorial
3. Summary of common problems in development
Question 1: The map does not display after the app is packaged?
The map does not display after the app is packaged. It may be that the map component is not checked in the manifest.json and the secret key of the AutoNavi map or Baidu map is configured. In this case, the map area will be displayed in white after the page containing the map is opened..
Question 2: Markers are not displayed after adding the map component?
In this case, we usually need to obtain the positioning point information from the backend, and dynamically display the positioning as markers on the map. At this time, the array bound by markers is dynamically changed. After changing the array bound by markers,The array bound to markers needs to be reassigned, for example:
markers=[{latitude: Obtained latitude,longitude: Obtained longitude,}]//Reassign markers each timeQuestion 3: The marker on Android is displayed normally, but the marker on ios cannot be displayed?
This situation may be caused by markers not configuring the id attribute when they are used (pro-test). It is recommended to refer to the usage in Uniapp's hello-uniapp when using it.
Question 4: The use of the relevant JS API of the map component is invalid?
In this case, the map object is obtained through uni.createMapContext, but the use of the related API is invalid.The page we use map must be configured in pages.json, and the page that can be used for routing jumps, otherwise the use of the relevant JS API will be invalid. When the blogger encounters this problem, he uses the relevant subNvue page.JS API.
️️The blogger is also a novice who uses uniapp to develop. If there is something wrong, thank you for correcting!️️
边栏推荐
- (3)Thinkphp6数据库
- Masashi: 1 vulnhub walkthrough
- By figure, a (complete code at the end)
- CTF-网鼎杯往届题目
- [mikehaertl/php-shellcommand] A library for invoking external command operations
- TypeScript error error TS2469, error TS2731 solution
- (2) Thinkphp6 template engine ** tag
- 3000字入门图神经网络
- (6) 学生信息管理系统设计
- 16. JS events, string and operator
猜你喜欢
随机推荐
【无标题】
学IT,找工作——反转链表
Sensitive information leakage
Praying: 1 vulnhub walkthrough
ES6 three-dot operator, array method, string extension method
[campo/random-user-agent] Randomly fake your User-Agent
(5) Modules and packages, encoding formats, file operations, directory operations
1. Beginning with PHP
战场:3(双子叶植物)vulnhub走读
(1) introduction to Thinkphp6, installation view, template rendering, variable assignment
WeChat applet development video loading: [Rendering layer network layer error] Failed to load media
Pycharm打包项目为exe文件
uniapp | Compilation error after updating with npm update
Solve the problem of uni - app packaged H5 website to download image
xxe of CTF
Basic use of v-on, parameter passing, modifiers
How to determine the direction based on two coordinate points on the map
hackmyvm: controller walkthrough
CTF入门笔记之SQL注入
By figure, a (complete code at the end)









