0

I'm using Mapbox GL JS, and I've found a private method that might be useful in solving a problem. It's _requestRenderFrame in map.js, and looks like this:

/**
 * Request that the given callback be executed during the next render
 * frame.  Schedule a render frame if one is not already scheduled.
 * @returns An id that can be used to cancel the callback
 * @private
 */
_requestRenderFrame(callback: () => void): TaskID {
    this._update();
    return this._renderTaskQueue.add(callback);
}

If I try to reference it in my project, I get undefined.

console.log(this.host.map['_requestRenderFrame']) // undefined;

When I search the mapbox package within my node_modules folder, I only see results for "_requestRenderFrame" in dist/mapbox-gl-dev.js.map.

There's other stuff that goes along with this feature that's not in there, so I can't really just hack the method back in on the fly.

I'm missing something. How can a method in source be omitted from compiled code? I have a hunch it may be just for testing??? But still, is there any way for me to use the omitted feature?

BBaysinger
  • 6,614
  • 13
  • 63
  • 132
  • 2
    Just checking you're using master since that method was only added recently so isn't in a release https://github.com/mapbox/mapbox-gl-js/pull/6328 – AndrewHarvey Apr 13 '18 at 03:08
  • Ah ha! K, I was looking at the version numbers, and they matched. So, that never ever even crossed my mind. So silly. – BBaysinger Apr 13 '18 at 04:00

0 Answers0