Nicolapps / mapkit-react

🗺⚛️ A React wrapper for MapKit JS
https://nicolapps.github.io/mapkit-react/
MIT License
58 stars 11 forks source link

showsPointsOfInterest not working on component mount #36

Closed nikischin closed 7 months ago

nikischin commented 1 year ago
image

The param showsPointsOfInterest is not considered in the initial load, however working if the param is refreshed. Easily reproducable at the Storybook.

Steps to reproduce:

  1. Open Map > Empty or Map > Custom Appearance storybook.
  2. Set showsPointsOfInterest to false
  3. Press Remount Component button

Current behavior: Points of interest are again visible

Expected behavior: Points of interest are not visible

Nicolapps commented 1 year ago

This looks strange, thank you for reporting it! A workaround you can use for now is to set includedPOICategories to [].

nikischin commented 1 year ago

It does work if I replace this line

https://github.com/Nicolapps/mapkit-react/blob/19129c1bf5353f5b86dc7c64be2824f66cd85614/src/components/Map.tsx#L203

with

delete map.pointOfInterestFilter;

However, as I get a TS error ts(2790) if I remove the ts ignore, I am not sure if this might cause some other issues maybe?

@Nicolapps could you have a look at it maybe? :)

nikischin commented 12 months ago

I figured out, mapkit-js generates quite some service calls while generating very few map calls. Apple limits the number of service calls to 25K while limiting the map calls to 250K, so someone using this lib more heavily might encounter some service call limits quite some time before the map call limits. In my experience I have like 50-100% more service calls than map calls. I haven't yet figured out the exact reason, though it seems like most interactions within the map (moving the visible area) are considered a service call. Not sure if it is connected with this issue also which could be responsible for some of the service calls, maybe it doesn't make a difference.

@Nicolapps Could you have a look at my previous comment or should I just open a PR for it? :)

Thank you!

Nicolapps commented 11 months ago

Hey, thank you for your observation. Does it look like from your data that the way mapkit-react works in order to set properties increase billed usage? If it is the case, we could try to find a way to handle initial state differently (i.e. pass these options to the constructor instead of setting properties). I would rather avoid doing this if it doesn’t matter since it will make the code more complicated, but it could be interesting if the current solution has a monetary cost.

nikischin commented 11 months ago

I further investigated, however, I still cannot tell for sure what creates service requests and what doesn't.

In any case though it seems a lot like without the showsPointsOfInterests it does generate some fewer service requests (but still some), than with those enabled. I personally in my implementation would want them to be disabled for other reasons, so would be happy if this fix (or any other fix for this issue) would be approved.

Thank you so much!