Skip to content
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

According to your documentation maps-api-for-javascript-examples shouldn't work #15

Open
TngCiemniak opened this issue May 2, 2019 · 0 comments
Labels

Comments

@TngCiemniak
Copy link

Dear Everyone

I have a problem getting your example to work if I use typescript. Actually the typescript definition on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/heremaps/index.d.ts seems to be wrong. But it follows your documentation, so I actually think your documentation is wrong. Or your actual implementation deviates from the documentation.
Documentation I am referring to: https://developer.here.com/documentation/maps/topics_api/h-mapevents-pointer.html#h-mapevents-pointer

I am implementing the very simple example from https://github.com/heremaps/maps-api-for-javascript-examples/blob/8712f6b62b6e87fa3fa3b43fbf32cf0783f6e90a/finding-the-nearest-marker/js/app.js

I don't follow your example but your documentation. According to https://developer.here.com/documentation/maps/topics_api/h-mapevents-pointer.html#h-mapevents-pointer viewportX and viewportY are static variables.

So if my understanding of javascript is correct you need to use the fields from the class, not from the instance. So your example

function addClickEventListenerToMap(map) {
  // add 'tap' listener
  map.addEventListener('tap', function (evt) {
    var coords =  map.screenToGeo(evt.currentPointer.viewportX, evt.currentPointer.viewportY);
    findNearestMarker(coords);
  }, false);
}

would not work, instead it would have to be

function addClickEventListenerToMap(map) {
  // add 'tap' listener
  map.addEventListener('tap', function (evt) {
    var coords =  map.screenToGeo(H.mapevents.Pointer.viewportX, H.mapevents.Pointer.viewportY);
    findNearestMarker(coords);
  }, false);
}

Reality shows that your implementation works while mine doesn't. So to my understanding your documentation is not correct. This in itself is not a problem, but the typescript implementation of the project is based on the documentation:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/heremaps/index.d.ts
So actually using typescript doesn't work here. So I'd like to change the typescript definition, but for that PR to go through I think you have to change your documentation first.

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

No branches or pull requests

2 participants