heremaps/harp.gl

Tutorial doesn't work

Closed this issue · 17 comments

Hello, Thank you for creating this wonderful app.

I wanted to use this map in a static HTML + CSS file and did a tutorial.

I added index.html and index.js in VS Code and pasted the API key. I then ran python -m SimpleHTTPServer 8888 and it doesn't work. (API key is pasted)

Specifically, when I open localhost: 8888, I see a page with just a gray background.

The console displays UncaughtReferenceError: mapView is not defined at index.js: 9.

The operating environment is Mac OS 10.15.6 and Google Chrome 86.0.4240.198.

I'm sorry if it's the problem already mentioned.

@takuto0515 , thanks for creating the issue!

I see the problem, sorry about that!

You need to change mapView to map. I will fix the tutorial.

All the best!

@nzjony Thank you for your reply! I succeeded in resolving the error by changing mapView to map.

But there is another problem. It looks like this:

Uncaught ReferenceError: GeoCoordinates is not defined

Is this also a related issue?

Yes, you need to change it to harp.GeoCoordinates

I am speaking with the guy to update the tutorial so that others don't have the same issue, thanks for your help!

@nzjony

Thank you for your prompt reply!

However, there seem to be a lot of dependencies in fixing this bug.

When I changed GeoCoordinates to harp.GeoCoordinates, I saw a panel such as a zoom button and a compass, but the console turned red.

I'm starting to wonder if you should fix this problem and wait for the tutorial to be updated.

I hope the problem is resolved !

What issue did you have in the console?

All going well you should see:

Screenshot 2020-11-19 at 09 07 57

const canvas = document.getElementById("map");
const map = new harp.MapView({
  canvas,
  theme:
    "https://unpkg.com/@here/harp-map-theme@latest/resources/berlin_tilezen_night_reduced.json",
});

// center the camera to New York
map.lookAt({
  target: new harp.GeoCoordinates(40.70398928, -74.01319808),
  zoomLevel: 17,
  tilt: 40,
});

const mapControls = new harp.MapControls(map);
const ui = new harp.MapControlsUI(mapControls);
canvas.parentElement.appendChild(ui.domElement);

map.resize(window.innerWidth, window.innerHeight);
window.onresize = () => map.resize(window.innerWidth, window.innerHeight);

const omvDataSource = new harp.OmvDataSource({
  authenticationCode: "<TOKEN>",
});
map.addDataSource(omvDataSource);

Is what I used to generate the image (you need your own token though).

Please confirm these.

スクリーンショット 2020-11-19 17 27 39

スクリーンショット 2020-11-19 17 27 51

スクリーンショット 2020-11-19 17 28 17

スクリーンショット 2020-11-19 17 28 27

スクリーンショット 2020-11-19 17 28 04

401 means you are unauthorized, i.e. the token you generated is invalid. How did you generate it?

I followed the tutorial to sign up for https://developer.here.com/ and got the API KEY from REST.

I copied the key from the image copy button and pasted it into index.js, is there something wrong?

スクリーンショット 2020-11-19 17 37 03

The image you sent said it is "Expired"

I wonder why....

Try to generate a new key.

I mean, I missed the API KEY deadline.

I tried issuing a new API KEY, but it also expires. Is this my problem?

スクリーンショット 2020-11-19 17 45 40

The second key you made says it is "Enabled", has it changed now to "Expired"?

Yes, the console errors you got are because your key is wrong.

I will ask internally how this can happen.

@takuto0515 , I spoke to someone internally, they said you have to confirm your email.

I.e.

Go to account section -> Send confirmation link to email

Thanks @gairik

As for the API KEY, it was just a misunderstanding.

I found that the map was successfully displayed in my development environment. Thank you!

@takuto0515 , glad to hear you got it working!!