Skip to content

Switch to OSM for maps #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
May 18, 2025
Merged

Conversation

pjaudiomv
Copy link
Collaborator

@pjaudiomv pjaudiomv commented May 7, 2025

This add support for OpenStreetMaps which doesn't require api keys. Obviously not as pretty and nice as the mapbox tiles but it allows maps to work with no key which is nice.

Updated PR description 5/17:

  • eliminates Mapbox and WebMercatorViewport, replaces with React Leaflet
  • drops bundle size from 1.4m minified to 572k (-60%)
  • replaces Mapbox geocoding for "Near Location" mode with new C4R geocoder
  • fixes minor UX papercuts:
    • refocuses map on markers when they change
    • opens marker window when there's only one marker
    • applies default distance to 5mi/km instead of making the user select
    • applies location search when changing modes and search is present
    • fixes overall tsml-ui height to be 100dvh

Copy link

netlify bot commented May 7, 2025

Deploy Preview for tsml-ui ready!

Name Link
🔨 Latest commit d29b886
🔍 Latest deploy log https://app.netlify.com/projects/tsml-ui/deploys/6828d32a34b7c800089affaf
😎 Deploy Preview https://deploy-preview-447--tsml-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@joshreisner
Copy link
Contributor

this works way better than i thought it would!

my first concern when i saw this was the bundle size - but turns out it doesn't bring it up by that much. before it's 1.4m and after it's 1.56m, so an increase of 150k basically

my second concern is maintaining two solutions - but what if we were to use only this and take mapbox out? then the bundle drops to 580kb, and no one needs to sign up for a mapbox account. also OSM is more aligned with the AA ethos.

there are some CSS issues that would need to get ironed out, but i can help with that. definitely something worth discussing at the next meeting

Screenshot 2025-05-08 at 8 31 33 PM Screenshot 2025-05-08 at 8 31 56 PM

@joshreisner
Copy link
Contributor

hey @pjaudiomv is it ok if i push a commit on this branch that removes mapbox (except to power location search) and fixes some CSS issues?

@pjaudiomv
Copy link
Collaborator Author

hey @pjaudiomv is it ok if i push a commit on this branch that removes mapbox (except to power location search) and fixes some CSS issues?

Oh I thought it was a fork but ya do whatever you need to do

@pjaudiomv
Copy link
Collaborator Author

Ya OSM is nice because free, open source, no api keys. no corporate entity tracking you. pretty big open source eco system. you can use different tile providers if wanted

@pjaudiomv
Copy link
Collaborator Author

oh weird it seems you already pushed, how does that work with a fork. either way ya go ahead

@joshreisner
Copy link
Contributor

yeah i synced with main already. later tonight ill try to push the change i mentioned

@pjaudiomv
Copy link
Collaborator Author

cool looks better fixed css, and its opening info modal with single meeting again

@joshreisner joshreisner changed the title Feat: Add support for OSM map if no mapbox key is provided Switch to OSM for maps May 10, 2025
@joshreisner
Copy link
Contributor

hi @Hiro-Tokyo we're considering a change to TSML UI away from Mapbox to Open Street Maps. these are less pretty but they are free!

before we change i wanted to check with you that this doesn't majorly degrade the experience in japan? here is a demo: https://deploy-preview-447--tsml-ui.netlify.app/tests/japan.html?view=map

please let us know what you think! thanks

@Hiro-Tokyo
Copy link
Contributor

Hiro-Tokyo commented May 14, 2025

Hi @joshreisner Please let me check with some local service offices crew! I will let you know how we think about.

@Hiro-Tokyo
Copy link
Contributor

Hiro-Tokyo commented May 14, 2025

Are there any advantages and disadvantages?

@joshreisner
Copy link
Contributor

joshreisner commented May 14, 2025

hi @Hiro-Tokyo the main advantages are:

  • sites no longer need an account with mapbox or anyone (mapbox accounts now require a credit card on file and a valid address, which is causing some concern about possible charges)
  • allows us to simplify the code and make it easier for us to maintain
  • overall bundle size is 60% lower so tsml ui should load faster, whether the user uses maps or not

the main disadvantages

  • maps aren't as pretty (to me)
  • maps don't smoothly zoom in and out, they go in stages

given these tradeoffs, the team is leaning toward adopting the new approach, but we want to make sure there isn't a problem with the default appearance that would cause problems on non-english sites

スクリーンショット 2025-05-14 午後10 23 41

it is possible to use custom map appearances but we're still learning about that

right: 0;
}

@media ${media.lgAndUp} {
grid-auto-columns: minmax(0, 1fr);
grid-auto-flow: column;

& > div:nth-child(2) > div > div {
& > div:nth-of-type(2) > div > div {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react complains about nth-child

@@ -1,7 +1,7 @@
let mix = require('laravel-mix');
const webpack = require('webpack');

mix.options({publicPath: 'public/'});
mix.options({ publicPath: 'public/', processCssUrls: false });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this so the build step would not publish leaflet image files into the public directory

README.md Outdated
tiles_dark: {
attribution:
'&copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.png',
Copy link
Collaborator Author

@pjaudiomv pjaudiomv May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think stadiamaps requires a api key, like it works fine on 127.0.0.1 or localhost but in production you need a key. so to use darkmode you would have to do url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.png?api_key=db30b16c-caba-blah',

https://docs.stadiamaps.com/authentication/#local-development

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see https://gist.github.com/BrendonKoz/b1df234fe3ee388b402cd8e98f7eedbd I did see a response on this fun thread from OSM team that they are working on actual darkmode vectors https://en.osm.town/@osm_tech/113482687301656785

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks that's a good callout - this is the dark mode value that i added to the aasanjose story (i didn't need an API key but i did need to set up authorized domains). i just added this as an example for the documentation, but perhaps i should either make this obviously fictitious or pick another one that works out of the box?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find one that didn't need a key, I think either make fictions or just add note about possibly needing keys for different map providers

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this totally works

map: {
    tiles: {
        attribution: `Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>`,
        url: 'https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ij_MY_KEY_HERE',
    },
    tiles_dark: {
        attribution: `Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>`,
        url: 'https://api.mapbox.com/styles/v1/mapbox/dark-v10/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ij_MY_KEY_HERE',
    },
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if you wanted to you could still support mapbox with the smallest of code changes (just pass in key to tiles)

@Hiro-Tokyo
Copy link
Contributor

Hiro-Tokyo commented May 16, 2025

Hi @joshreisner

Thank you for your information!

We think it will be okay to change to Open Street Map basically. OSM information provides some old information, venue name, street name... so we need to edit them, though.

@joshreisner joshreisner merged commit 45dd706 into code4recovery:main May 18, 2025
4 of 5 checks passed
@Hiro-Tokyo
Copy link
Contributor

Hi @joshreisner seemed already changed to OSM so can we remove MapBox settings on our website?

@joshreisner
Copy link
Contributor

@Hiro-Tokyo yes, but i would wait a month - just in case we need to roll back

@Hiro-Tokyo
Copy link
Contributor

@Hiro-Tokyo yes, but i would wait a month - just in case we need to roll back

Okay thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants