IN THIS ARTICLE
Subscribe to Our Newsletter
Electric Scooters have taken over the streets of San Francisco and other popular metropolitan cities. Recently there has been controversy surrounding whether these scooters cause a public nuisance and if the companies need to take actions to control where the scooters are allowed to be left by riders.
The city is willing to work with Bird, Spin & Lime since they want to see more green transportation methods come to the city. However, the process of leaving scooters on city streets is something that needs to be logistically fixed. Bird said publicly that it will begin to require riders to take a photo of where they drop off their scooters to take actions against vandals, however, it will have to be seen how the companies deal with the public outcry.
Create Your Own Scooter Share App
With Project EON, you can create your own rideshare scooter application in just a few minutes and try to address the problem that is facing these emerging companies. Each scooter in the fleet is an IoT device that sends GPS and location data to its servers so customers using the mobile application can see where the scooters are parked in realtime.
Creating an infrastructure that supports thousands of simultaneous users is a huge challenge for most companies. If you are using PubNub however, all of those scaling issues are taken care of for you so you can focus on innovating your application.
To get started, we are going to take a look at the Realtime Bus Map demo. In this initial code snippet, we initialize our PubNub keys and create our map. You have to setup your API keys through MapBox. Click the button below to generate your PubNub keys for Project EON.
var pubnub = new PubNub({ publishKey: 'INSERT PUBNUB KEYS HERE', subscribeKey: 'INSERT PUBNUB KEYS HERE' }); eon.map({ id: 'map', mbId: 'YOUR_MAPBOX_ID', mbToken: 'YOUR_MAPBOX_TOKEN', channel: 'scooterchannel', rotate: true, history: true, marker: function (latlng, data) { var marker = new L.RotatedMarker(latlng, { icon: L.icon({ iconUrl: 'https://i.imgur.com/2fmFQfN.png', iconSize: [9, 32] }) }); marker.bindPopup('Route ' + data.routeTag.toUpperCase()); return marker; } });
The code below is a publish function which publishes location information from each IoT device connected to the internet. Essentially each scooter would have this code running on the device, and would publish location information intermittently (can change time in the setInterval function).
var pubnub = new PubNub({ publishKey: 'INSERT PUBNUB KEYS HERE', subscribeKey: 'INSERT PUBNUB KEYS HERE' }); setInterval(function(){ pubnub.publish({ channel: 'scooterchannel', message: [ {"latlng":[31,-99]}, {"latlng":[32,-100]}, {"latlng":[33,-101]}, {"latlng":[35,-102]} ] }); }, 1000);
And that’s it folks! It’s really that easy to set up a scalable realtime location tracking application with PubNub and Project EON.
If you want to learn more and start building your first application, check out Project EON and PubNub. If you have any questions, reach out to me at schuetz@pubnub.com.