Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HMS Core
HuaweiMapEx provides the following route drawing functions:
Call the addRouteLine method of HuaweiMapEx to draw a route on the map.
- public void addRouteLine(View view) {
- if (null == hMapEx) {
- return;
- }
- if (null != nRouteLine) {
- nRouteLine.remove();
- nRouteLine = null;
- }
- if (null != gRouteLine) {
- gRouteLine.remove();
- gRouteLine = null;
- }
- // Add a route.
- nRouteLine = hMapEx.addRouteLine(new RouteLineOptions().add(new LatLng(47.893478, 2.334595),
- new LatLng(48.993478, 3.434595),
- new LatLng(48.693478, 2.134595),
- new LatLng(48.793478, 2.334595)));
- gRouteLine = hMapEx.addRouteLine(new RouteLineOptions().add(
- new LatLng(47,3),
- new LatLng(47,4),
- new LatLng(48,4),
- new LatLng(48,5),
- new LatLng(48,4),
- new LatLng(49,4))
- );
- }
- fun addRouteLine(view: View?) {
- if (null == hMapEx) {
- return
- }
- if (null != nRouteLine) {
- nRouteLine!!.remove()
- nRouteLine = null
- }
- if (null != gRouteLine) {
- gRouteLine!!.remove()
- gRouteLine = null
- }
- // Add a route.
- nRouteLine = hMapEx.addRouteLine(RouteLineOptions().add(LatLng(47.893478, 2.334595),
- LatLng(48.993478, 3.434595),
- LatLng(48.693478, 2.134595),
- LatLng(48.793478, 2.334595)))
- gRouteLine = hMapEx.addRouteLine(RouteLineOptions().add(
- LatLng(47.0, 3.0),
- LatLng(47.0, 4.0),
- LatLng(48.0, 4.0),
- LatLng(48.0, 5.0),
- LatLng(48.0, 4.0),
- LatLng(49.0, 4.0))
- )
- }

Call the setLabelsText method of RouteLine to set the road name.
- private final List<String> textListLabel = new ArrayList<>();
- private final List<Integer> indexListLabel = new ArrayList<>();
- public void setLabelsText(View view) {
- try{
- if (null != nRouteLine) {
- // Set the road name.
- textListLabel.add("text");
- indexListLabel.add(1);
- indexListLabel.add(3);
- nRouteLine.setLabelsText(textListLabel,indexListLabel,"EN",false);
- }
- }catch (Exception e){
- }
- }
- private var textListLabel : ArrayList<String> = ArrayList()
- private var indexListLabel: ArrayList<Int> = ArrayList()
- fun setLabelsText(view : View?) {
- try{
- if (null != nRouteLine) {
- // Set the road name.
- textListLabel.add("text")
- indexListLabel.add(1)
- indexListLabel.add(3)
- nRouteLine!!.setLabelsText(textListLabel,indexListLabel,"EN",false)
- }
- }catch (e : Exception ){
- }
- }

Create a LineExtendAnimation object and set its attributes. Call the setAnimation method of RouteLine to set the extension animation, and then call the startAnimation method to start the animation.
- public void extendAnimation(View view) {
- if(nRouteLine == null){
- Toast.makeText(this, "Please add RouteLine first.", Toast.LENGTH_SHORT).show();
- return;
- }
- extendAnimation = new LineExtendAnimation();
- extendAnimation.setDuration(5000);
- extendAnimation.setInterpolator(LineAnimation.LineInterpolator.LINEARINTERPOLATOR);
- // Add the extension animation for the route.
- nRouteLine.setAnimation(extendAnimation);
- // Start the animation.
- nRouteLine.startAnimation();
- }
- lateinit var extendAnimation : LineExtendAnimation;
- fun extendAnimation(view: View?) {
- if (nRouteLine == null) {
- Toast.makeText(this, "Please add RouteLine first.", Toast.LENGTH_SHORT).show()
- return
- }
- extendAnimation = LineExtendAnimation()
- extendAnimation.duration = 5000
- extendAnimation.interpolator = LineAnimation.LineInterpolator.LINEARINTERPOLATOR
- // Add the extension animation for the route.
- nRouteLine!!.setAnimation(extendAnimation)
- // Start the animation.
- nRouteLine!!.startAnimation()
- }

Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.