Mapbox-gl-js: Marker element click event throws: Uncaught TypeError: Cannot read property 'x' of null

Created on 1 Feb 2019  路  7Comments  路  Source: mapbox/mapbox-gl-js

mapbox-gl-js version: 0.52.0

browser: macOS Chrome Version 71.0.3578.98 (Official Build) (64-bit)

Steps to Trigger Behavior

  1. add a html marker;
  2. add event by addEventListener to marker's html dom;
  3. fire the event, throws the error: Uncaught TypeError: Cannot read property 'x' of null

Link to Demonstration

https://jsfiddle.net/ParryQiu/hnkwqfue/12/

console out put error:

vendor.js:51848 ERROR TypeError: Cannot read property 'x' of null
    at a.equals (vendor.js:18268)
    at HTMLDivElement.<anonymous> (vendor.js:18272)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2745)
    at Object.onInvokeTask (vendor.js:53986)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2744)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (polyfills.js:2517)
    at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (polyfills.js:2820)
    at invokeTask (polyfills.js:4066)
    at HTMLDivElement.globalZoneAwareCallback (polyfills.js:4092)
    at Map.<anonymous> (main.js:7314)
bug good first issue

Most helpful comment

All 7 comments

Because startPos set when onMouseDown is triggered(bind_handlers.js#L155, L60). So, if click is triggered programatically, startPos is not set, then throw Error.

@cs09g good find! Want to submit a PR with the fix?

@mourner sure :) but I'm off about a week for holiday so, it would be taking a week.

@cs09g Thanks very much, I fixed this issue in local repository.
After doing some testing, consider submitting a PR.

@ParryQiu Are you able to commit the fix?

+1 - having the exact same issue on v 0.53.1 and only seeing it when triggering a marker click programmatically.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevage picture stevage  路  3Comments

muesliq picture muesliq  路  3Comments

aendrew picture aendrew  路  3Comments

aderaaij picture aderaaij  路  3Comments

Scarysize picture Scarysize  路  3Comments