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

Expose mapboxgl.rtlTextPluginRequested boolean #8585

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions debug/rtl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<title>Mapbox GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel='stylesheet' href='/dist/mapbox-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>

<body>
<div id='map'></div>

<script src='/dist/mapbox-gl-dev.js'></script>
<script src='/debug/access_token_generated.js'></script>
<script>

mapboxgl.setRTLTextPlugin('https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js');

var map = window.map = new mapboxgl.Map({
container: 'map',
zoom: 16.5,
center: [44.355435, 33.258814],
style: 'mapbox://styles/mapbox/streets-v11',
hash: true
});

map.on('load', function () {
if (!mapboxgl.rtlTextPluginRequested) {
mapboxgl.setRTLTextPlugin('https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js');
}
});

</script>
</body>
</html>
1 change: 1 addition & 0 deletions docs/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ toc:
- supported
- version
- setRTLTextPlugin
- rtlTextPluginRequested
Copy link
Member

Choose a reason for hiding this comment

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

Note that this file is being moved over to https://github.com/mapbox/mapbox-gl-js-docs — should we keep it in this repo? We could either keep it, or move it over but PR ToC changes to the docs repo after a release separately. cc @colleenmcginnis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm willing to defer to you and Colleen on whether this file should be moved or not since you have both thought about this way more than I have. This isn't super urgent so I can wait until we get the docs separated in order to merge this PR. That gives us time to figure out what we want to do with the ToC.

Copy link
Contributor

Choose a reason for hiding this comment

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

should we keep it in this repo? We could either keep it, or move it over but PR ToC changes to the docs repo after a release separately.

It would be better to move this over to docs, and add a step to the post-release PR for docs repo to ensure that these types of changes get added to the ToC.

- clearStorage
- AnimationOptions
- CameraOptions
Expand Down
15 changes: 14 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Point from '@mapbox/point-geometry';
import MercatorCoordinate from './geo/mercator_coordinate';
import {Evented} from './util/evented';
import config from './util/config';
import {setRTLTextPlugin} from './source/rtl_text_plugin';
import {setRTLTextPlugin, rtlTextPluginRequested} from './source/rtl_text_plugin';
import WorkerPool from './util/worker_pool';
import {clearTileCache} from './util/tile_request_cache';

Expand Down Expand Up @@ -91,6 +91,19 @@ const exported = {
WorkerPool.workerCount = count;
},

/**
* Gets a boolean indicating whether or not the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text) has been previously requested
*
* @var {string} rtlTextPluginRequested
* @example
* if (!mapboxgl.rtlTextPluginRequested) {
* mapboxgl.setRTLTextPlugin('https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js');
* }
*/
get rtlTextPluginRequested(): boolean {
return rtlTextPluginRequested();
},

/**
* Gets and sets the maximum number of images (raster tiles, sprites, icons) to load in parallel,
* which affects performance in raster-heavy maps. 16 by default.
Expand Down
4 changes: 4 additions & 0 deletions src/source/rtl_text_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const registerForPluginAvailability = function(
return callback;
};

export const rtlTextPluginRequested = function () {
return pluginRequested;
};

export const clearRTLTextPlugin = function() {
pluginRequested = false;
pluginURL = null;
Expand Down