CurrentLocation
Example Usage
<div class='my-location'></div>
// Pull in the library
const UI = require('jibe-juice');
// Instantiate a component, pass the selector of the container to insert component into and the opts
const currentLocation = new UI.CurrentLocation('.my-location', {
geolocationAPI: window.navigator.geolocation
});
// Subscribe to fire this function whenever the current location component is clicked
currentLocation.subscribe(function (msg) {
if (msg.isLocation) {
console.log('Users current location is', msg);
} else {
console.log(msg);
}
});
// Render the DOM for the CurrentLocation component
currentLocation.render();
params
| Name | Type | Default | Description |
|---|---|---|---|
| el | string | undefined | A string of the selector for the element to put the component in |
| opts | object | {} | A catch all for various options. See the opts table below for options specific to this component. |
opts
| Name | Type | Default | Description |
|---|---|---|---|
| geolocationAPI | * | window.navigator.geolocation | The API to use to get the current location |
| iconURL | string | By default will use our built in location.png | The path to the icon image to use |
Updated less than a minute ago
Did this page help you?
