From cde46bec33b4ac6d5e977618929b1393ff0ffe1d Mon Sep 17 00:00:00 2001 From: Heather Stenson Date: Mon, 20 Apr 2020 15:41:49 -0700 Subject: [PATCH] [docsprint] Add inline snippet to marker#setPopup, marker#getPopup, and marker#togglePopup (#9582) * update setPopup * update getPopup * update togglePopup * update formatting --- src/ui/marker.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/ui/marker.js b/src/ui/marker.js index b1b5f130f4e..7fe090c1394 100644 --- a/src/ui/marker.js +++ b/src/ui/marker.js @@ -309,10 +309,16 @@ export default class Marker extends Evented { } /** - * Binds a Popup to the Marker - * @param popup an instance of the `Popup` class. If undefined or null, any popup - * set on this `Marker` instance is unset + * Binds a `Popup` to the `Marker`. + * @param popup An instance of the `Popup` class. If undefined or null, any popup + * set on this `Marker` instance is unset. * @returns {Marker} `this` + * @example + * var marker = new mapboxgl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new mapboxgl.Popup().setHTML("

Hello World!

")) // add popup + * .addTo(map); + * @see [Attach a popup to a marker instance](https://docs.mapbox.com/mapbox-gl-js/example/set-popup/) */ setPopup(popup: ?Popup) { if (this._popup) { @@ -376,16 +382,30 @@ export default class Marker extends Evented { } /** - * Returns the Popup instance that is bound to the Marker + * Returns the `Popup` instance that is bound to the `Marker`. * @returns {Popup} popup + * @example + * var marker = new mapboxgl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new mapboxgl.Popup().setHTML("

Hello World!

")) + * .addTo(map); + * + * console.log(marker.getPopup()); // return the popup instance */ getPopup() { return this._popup; } /** - * Opens or closes the bound popup, depending on the current state + * Opens or closes the `Popup` instance that is bound to the `Marker`, depending on the current state of the `Popup`. * @returns {Marker} `this` + * @example + * var marker = new mapboxgl.Marker() + * .setLngLat([0, 0]) + * .setPopup(new mapboxgl.Popup().setHTML("

Hello World!

")) + * .addTo(map); + * + * marker.togglePopup(); // toggle popup open or closed */ togglePopup() { const popup = this._popup;