# Routing Algorithm Choosing Longer Paths Than Necessary

**URL:** <https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249>\
**Category:** Mappedin JS\
**Created:** [March 11, 2025, 10:31am UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249 "2025-03-11T10:31:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Markus](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Markus](https://community.mappedin.com/u/Markus)\
**Post date:** [March 11, 2025, 10:31am UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/1 "2025-03-11T10:31:49Z")

</div>

Hi everyone,

I’m currently working on drawing a map in the Mappedin Editor and have been testing the routing functionality with different POIs. I noticed that in several cases, the routing algorithm selects a longer path instead of the shortest possible one.

For clarification, I’ve attached a screenshot showing an example of this behavior.

 ![Mappedin_Route](https://canada1.discourse-cdn.com/flex004/uploads/mappedin/original/1X/79790d88117e70d23e9cced1d8ebef5203cd6ded.jpeg)

Is there a way to adjust the routing settings or prevent this from happening? Any insights would be greatly appreciated!

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![msohm](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/msohm/32/6_2.png) [@msohm](https://community.mappedin.com/u/msohm)\
**Post date:** [March 11, 2025, 1:44pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/2 "2025-03-11T13:44:33Z")

</div>

Hi Markus,

Welcome to the forum! It looks like something has gone wrong during the path generation of your map. Could you share the Map ID with me so I can take a look? Feel free to DM it to me if you’d prefer not to post it publicly.

Mark

---

<div class="post-metadata">

**Author:** ![Markus](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Markus](https://community.mappedin.com/u/Markus)\
**Post date:** [March 11, 2025, 2:36pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/3 "2025-03-11T14:36:42Z")

</div>

Hey Mark,  
thanks for the quick reply.

My colleague has send you a DM with the Map ID, since I didn’t see any option to do so from my Account.

---

<div class="post-metadata">

**Author:** ![msohm](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/msohm/32/6_2.png) [@msohm](https://community.mappedin.com/u/msohm)\
**Post date:** [March 11, 2025, 2:58pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/4 "2025-03-11T14:58:56Z")

</div>

Thanks, you may not have that option right away after making an account here.

I’ve received the map ID and am investigating.

---

<div class="post-metadata">

**Author:** ![msohm](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/msohm/32/6_2.png) [@msohm](https://community.mappedin.com/u/msohm)\
**Post date:** [March 14, 2025, 1:59pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/5 "2025-03-14T13:59:47Z")

</div>

Thank you for reporting this. We have resolve the issue that was causing the directions to not use the most efficient route. Please update to Mappedin JS v6.0.1-beta.34 to pick up this fix and let us know if you run into any further issues.

---

<div class="post-metadata">

**Author:** ![Niko](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@Niko](https://community.mappedin.com/u/Niko)\
**Post date:** [March 17, 2025, 11:51am UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/6 "2025-03-17T11:51:25Z")

</div>

We tried the latest Mappedin JS release. The paths are now drawn better but on Safari and iOS this version is worse than the one we used before. The red floors for the security checks are now sometimes drawn on spaces where they should be black and there seem to be display errors for the red floors. This seems only to happen on Safari and iOS (you can also check on a Desktop PC with Chrome Browser), the WebView is using Safari. You can fix these issues but we will stay on the old version (beta.30).

 ![display errors red floors](https://canada1.discourse-cdn.com/flex004/uploads/mappedin/original/1X/da105cb1a813348796cd27b4faa450337d52c00b.jpeg)

---

<div class="post-metadata">

**Author:** ![msohm](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/msohm/32/6_2.png) [@msohm](https://community.mappedin.com/u/msohm)\
**Post date:** [March 17, 2025, 1:02pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/7 "2025-03-17T13:02:50Z")

</div>

Can you describe how you are changing the color? Are you using changing the space color, using Shapes or Textures? A code snippet would be helpful here that I could use to reproduce. I tested our examples that change space color and didn’t see this behaviour yet.

---

<div class="post-metadata">

**Author:** ![Niko](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@Niko](https://community.mappedin.com/u/Niko)\
**Post date:** [March 17, 2025, 1:16pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/8 "2025-03-17T13:16:51Z")

</div>

This is the code we use to set the floor color to red.

```auto
    const spaces = mapData
        .getByType("space")
        .filter((space: any) => space.floor.id === "m_f2786e5df102b3c5");
    for (const space of spaces) {
        const description = space.description.toLowerCase();
        if (description.includes("red")) {
            // Security check
            mapView.updateState(space, {
                color: "#F88E86",
            });
        } else {
            //Floors
            mapView.updateState(space, {
                color: "#00080A",
            });
        }
    }

```

The beta.30 version does not have this issue, we already reverted back to the old version and it is fine.

---

<div class="post-metadata">

**Author:** ![msohm](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/msohm/32/6_2.png) [@msohm](https://community.mappedin.com/u/msohm)\
**Post date:** [March 17, 2025, 7:24pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/9 "2025-03-17T19:24:45Z")

</div>

Thank you for the example. We’ve found the change that is causing this issue on some maps and will have a fix out soon.

---

<div class="post-metadata">

**Author:** ![msohm](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.mappedin.com/msohm/32/6_2.png) [@msohm](https://community.mappedin.com/u/msohm)\
**Post date:** [March 18, 2025, 3:13pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/10 "2025-03-18T15:13:01Z")

</div>

We have just released Mappedin JS v6.0.1-beta.35, which resolves the issue you reported with space visibility on Safari on iOS.

---

<div class="post-metadata">

**Author:** ![Niko](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@Niko](https://community.mappedin.com/u/Niko)\
**Post date:** [March 18, 2025, 3:47pm UTC](https://community.mappedin.com/t/routing-algorithm-choosing-longer-paths-than-necessary/249/11 "2025-03-18T15:47:16Z")

</div>

Thank you for the update. We will stay at beta.30 for now, since we had done a code-freeze. In case we will update to the latest version, as suggested by you, I will post an update with the results.
