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

[docsprint] Add inline snippet to marker#setPopup, marker#getPopup, and marker#togglePopup #9582

Merged
merged 4 commits into from
Apr 20, 2020
Merged
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
30 changes: 25 additions & 5 deletions src/ui/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,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`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you think it'll be better to actually link to #popup here too? I find these internal links very helpful myself.

* @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("<h1>Hello World!</h1>")) // 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) {
Expand Down Expand Up @@ -364,16 +370,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("<h1>Hello World!</h1>"))
* .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("<h1>Hello World!</h1>"))
* .addTo(map);
*
* marker.togglePopup(); // toggle popup open or closed
*/
togglePopup() {
const popup = this._popup;
Expand Down