I am trying to add map style to Huawei map for my app. I had made a JSON file for style from Huawei map style editor and use it in setMapStyle method by MapStyleOptions.loadRawResourceStyle and passing the JSON file. I used huawei simple map and add some custom style to it. When I first open the app then the default map (simple) is loaded and the custom styles from JSON is not applied, but I go back to the previous screen and again launch the map screen then the style from JSON is properly applied. How to solve the problem for the first time launch?
Asked
Active
Viewed 122 times
2

zhangxaochen
- 32,744
- 15
- 77
- 108

Partho Bhowmick
- 29
- 2
-
Welcome to StackOverflow, please do read https://stackoverflow.com/help/how-to-ask to learn about how to write a good question. Make sure to always include relevant code in your questions. – DevWithZachary Aug 25 '21 at 08:41
1 Answers
0
First you can follow this development documents all Steps:
setMapStyle
method by MapStyleOptions.loadRawResourceStyle
and passing the JSON file, this is load the local map.
To fix the problem need to change the cloud load mapstyle , see the above docs's Step 5:
Using a custom style after a map is created
Call the setStyleId
and previewId
methods in HuaweiMap to use a custom map style.
The sample code is as follows:
HuaweiMap hMap;
// Specify a style ID after a map is created.
hMap.setStyleId(String styleId);
// Specify a preview ID after a map is created.
hMap.previewId(String previewId);
Using a custom style before a map is created
Call the styleId
and previewId
methods in HuaweiMapOptions
to use a custom map style. If both styleId
and previewId
are set, styleId
takes precedence.
The sample code is as follows:
HuaweiMapOptions huaweiMapOptions;
// Specify a style ID before a map is created.
huaweiMapOptions.styleId(String styleId);
// Specify a preview ID before a map is created.
huaweiMapOptions.previewId(String previewId);
use method above will change the cloud map for the first time.

zhangxaochen
- 32,744
- 15
- 77
- 108
-
I follow the same instruction. but didn't get the expected result. – Partho Bhowmick Aug 29 '21 at 11:41
-
hi@Partho Bhowmick, you can try to clear the HMS Core apk cache. Also could you pls post some of your updated code? – zhangxaochen Aug 30 '21 at 01:46
-
Hi @shirley we communicate with Huawei Engineering team regarding map style. It is already a known issue from Huawei HQ. – Partho Bhowmick Sep 04 '21 at 04:31