Skip to content

setOrigin and setDestination changing others maps directions #170

@aless673

Description

@aless673

Hi,

I have 2 classes with 2 differents maps with differents containers.
When i made changes on one map, this is independant from the other map, excepts for setOrigin and setDestination. Those 2 functions impacts the two independants directions instances.

Class 1

this.map1 = new mapboxgl.Map({
      container: 'map1',
      style: 'mapbox://styles/mapbox/streets-v10',
    });

this.directions1 = new MapboxDirections({
      accessToken: mapboxgl.accessToken,
      unit: 'metric',
      profile: 'walking',
      interactive: false,
      controls: {
        inputs: false,
        instructions: false,
        profileSwitcher: false
      }
    });
    this.map1.addControl(this.directions);
... 
this.directions1.setOrigin([lon, lat]);
this.directions1.setDestination([lon+1, lat+1]);

Class 2

this.map2 = new mapboxgl.Map({
      container: 'map2',
      style: 'mapbox://styles/mapbox/streets-v10',
    });

this.directions2 = new MapboxDirections({
      accessToken: mapboxgl.accessToken,
      unit: 'metric',
      profile: 'walking',
      interactive: false,
      controls: {
        inputs: false,
        instructions: false,
        profileSwitcher: false
      }
    });
    this.map2.addControl(this.directions);
... 
this.directions2.setOrigin([lon+3, lat+3]);
this.directions2.setDestination([lon+3, lat+3]);

Problem : the setOrigin and setDestination from directions2 impacts the direction1 instance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions