Configuration API for EON Map SDK
EON Map complete API reference for building real-time applications on PubNub, including basic usage and sample code
Initialization
Call eon.map({}). Check out the table of options below for more information.
Description
This function is used for initializing the PubNub Client API context. This function must be called before attempting to utilize any API functionality in order to establish account level credentials such as publishKey and subscribeKey.
Method(s)
To Initialize PubNub you can use the following method(s) in the EON Map SDK:
| Parameter | Description | 
|---|---|
| idType:  Default: undefined | The ID of the element where the map will be rendered. | 
| channelsType: Array Default: false | An array of PubNub channels to subscribe to. Either channelsorchannelGroupsmust be supplied. | 
| channelGroupsType: Array Default: false | An array of PubNub channel groups to subscribe to. Either channelsorchannelGroupsmust be supplied. | 
| transformType:  Default: function(m){} | Method for changing the payload format of your stream. | 
| historyType:  Default: false | Use PubNub history call to retrieve last message. This will display points at their last known location. Requires Message Persistence to be enabled. | 
| pubnub*Type: Instance Default: false | An instance of the PubNub javascript global. This is required when using your own keys. See the subscribeKeyexample. | 
| connectType:  Default: function(){} | A function to call when PubNub makes a connection. See PubNub subscribe | 
| markerType:  Default: L.marker | A custom Mapbox marker object. Use this to change the marker icon, tooltip, etc. | 
| rotateType:  Default: false | Add bearing to markers in options.angle. This won't have any effect unless you're using a rotated marker type | 
| messageType:  Default: function(message, timetoken, channel){} | A function to call everytime a PubNub message is received. See PubNub subscribe | 
| transformType:  Default: function(m){return m} | Method for changing the payload format of your stream. | 
| providerType:  Default: mapbox | Google or Mapbox | 
| mbTokenType:  Default: undefined | Mapbox API Token (Mapbox Only). | 
| mbIdType:  Default: undefined | Mapbox Map ID (MapBox Only). | 
| optionsType:  Default: {} | An options object supplied to the MapBox Maps constructor (MapBox Only). | 
| googleKeyType:  Default: undefined | Google Maps API Key (Google Maps Only) | 
| googleMutantType:  Default: { type: 'roadmap'} | Configure Google Maps Styles and Options as documented in Google Mutant Plugin | 
Sample code
Initialize the PubNub client API
Required UUID
Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the UUID, you won't be able to connect to PubNub.
1let pubnub = new PubNub({
2    subscribeKey: "mySubscribeKey",
3    publishKey: "myPublishKey",
4    cipherKey: "myCipherKey",
5    authKey: "myAuthKey",
6    logVerbosity: true,
7    uuid: "myUniqueUUID",
8    ssl: true,
9    presenceTimeout: 130
10});
Returns
It returns the PubNub instance for invoking PubNub APIs like publish(), subscribe(), history(), hereNow(), etc.
Other examples
Configure using your own PubNub API keys
1<div data-id="map"></div>
2<script>
3    let pn  = new PubNub({
4        subscribeKey : 'YOUR_SUB_KEY',
5        ssl : true
6    });
7    let channel = 'my-map';
8    let map = eon.map({
9        pubnub: pn,  // PubNub goes here
10        channels: channel,
11        id: 'map',
12        mbId 'mapbox.streets',
13        mbToken: 'pk.ey31IjoiaWRtc3giLCJhIjoiZZ1zMGI2ZjBlNTMxZjk5YTEwNjM5WNJlOWI4MmJiZGIifQ.U1jMQo2QVeuUtt85oD7hkQ'
14    });
15</script>
Marker customization
You can supply a custom Mapbox marker object with custom tooltips by extening the L.marker object provided by mapbox. Learn more about custom markers here
Required UUID
Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the UUID, you won't be able to connect to PubNub.
1<div data-id='map'></div>
2<script>
3    L.RotatedMarker = L.Marker.extend({
4        options: { angle: 0 },
5        _setPos: function(pos) {
6            L.Marker.prototype._setPos.call(this, pos);
7            if (L.DomUtil.TRANSFORM) {
8                // use the CSS transform rule if available
9                this._icon.style[L.DomUtil.TRANSFORM] += ' rotate(' + this.options.angle + 'deg)';
10            } else if (L.Browser.ie) {
11                // fallback for IE6, IE7, IE8
12                let rad = this.options.angle * L.LatLng.DEG_TO_RAD,
13                costheta = Math.cos(rad),
14                sintheta = Math.sin(rad);
15                this._icon.style.filter += ' progid:DXImageTransform.Microsoft.Matrix(sizingMethod=\'auto expand\', M11=' +
Following a point
You can tell the map to follow a point to it's new location whenever data is received by supplying a message callback.
Required UUID
Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the UUID, you won't be able to connect to PubNub.
1let pn = new PubNub({
2    publishKey:   'YOUR_PUB_KEY', // replace with your own pub-key
3    subscribeKey: 'YOUR_SUB_KEY'  // replace with your own sub-key
4});
5
6let map = eon.map({
7    pubnub: pn,
8    id: 'map',
9    mbId: 'ianjennings.l896mh2e',
10    //...
11    message: function (data) {
12        map.setView(data[3].latlng, 13);
13    }
14});