Skip to content

Conversation

TeriyakiBomb
Copy link
Contributor

As discussed here ember-learn/guides-source#1938 Map Box no longer allows access without a credit card, but TomTom does! (There's a cute joke in there somewhere) so this replaces Map Box.

Hopefully not missed anything.

@MinThaMie
Copy link
Contributor

Thanks for making this :)I've pinged @mansona personally to figure out why the build breaks

@MinThaMie
Copy link
Contributor

We'll first merge the gjs PR and then @tcjr will help us merge your fix into that new status!

@MinThaMie
Copy link
Contributor

@tcjr what's the best way to move this change now?

@tcjr
Copy link
Contributor

tcjr commented Sep 9, 2025

@tcjr what's the best way to move this change now?

I was just thinking that I'm not entirely sure how to go about this.

The bad news

I just looked at the merge conflicts and I don't think there's really any way to reconcile it in a traditional way. The nature of the changes in the base -- merging .js + .hbs => .gjs -- makes the diff a mess.

The good news

We are very fortunate that it's just this one chapter and the changes are completely self-contained. The component signature doesn't change, so subsequent mods around the Map component aren't affected. Yay encapsulation!

I think the best approach might be to create a new branch and manually copy the changes into the new .gjs files from either the .hbs or the .js. Unless somebody has a better suggestion, I can take a stab at it this morning and see if that works out ok.

Thoughts? @TeriyakiBomb

@TeriyakiBomb
Copy link
Contributor Author

It's just the one chapter as you say, so that's probably the easiest way to do it TBH

Copy link
Contributor

@tcjr tcjr left a comment

Choose a reason for hiding this comment

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

This is close; just a few things to update.

I'll make a PR to address these things.

+ <img
+ alt="Map image at coordinates {{@lat}},{{@lng}}"
+ ...attributes
+ src="https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/{{@lng}},{{@lat}},{{@zoom}}/{{@width}}x{{@height}}@2x?access_token={{this.token}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to go to api.tomtom.com. The API is different too, so it's more than just swapping out the domain.

The src attribute should be:

src="https://api.tomtom.com/map/1/staticimage?key={{this.token}}&zoom={{@zoom}}&center={{@lng}},{{@lat}}&width={{@width}}&height={{@height}}"

The `src` attribute interpolates all the required parameters into the URL format for Mapbox's [static map image API](https://docs.mapbox.com/api/maps/#static-images), including the URL-escaped access token from `this.token`.
The `src` attribute interpolates all the required parameters into the URL format for TomTom's [static map image API](https://developer.tomtom.com/map-display-api/documentation/raster/static-image), including the URL-escaped access token from `this.token`.

Finally, since we are using the `@2x` "retina" image, we should specify the `width` and `height` attributes. Otherwise, the `<img>` will be rendered at twice the size than what we expected!
Copy link
Contributor

Choose a reason for hiding this comment

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

The @2x query param is is specific to Mapbox, so this paragraph should be removed.

+ );
+
+ assert.ok(
+ src.includes('-122.4184,37.7797,10'),
Copy link
Contributor

Choose a reason for hiding this comment

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

TomTom API does this differently. These values are no longer URL segments and are now part of the center and zoom query params.

- await render(<template><Map /></template>);
+ assert.ok(
+ src.includes('150x120@2x'),
Copy link
Contributor

Choose a reason for hiding this comment

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

No @2x in TomTom.

- assert.dom().hasText('');
+ assert.ok(
+ src.includes(`access_token=${token}`),
Copy link
Contributor

Choose a reason for hiding this comment

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

TomTom calls this key instead of access_token.

+ let img = find('.map img');
+
+ assert.ok(
+ img.src.includes('-122.4194,37.7749,10'),
Copy link
Contributor

Choose a reason for hiding this comment

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

All these assertions have to change to reflect the TomTom API. (see above)

@tcjr
Copy link
Contributor

tcjr commented Sep 27, 2025

This can be closed. The other PR contains the commit from this PR (plus a couple more commits):
#271

@mansona mansona merged commit 0be5b35 into ember-learn:main Sep 27, 2025
3 of 5 checks passed
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.

4 participants