Mapbox跟踪服务公司资产

时间:2019-01-15 13:15:30

标签: ionic-framework

我们从开发Ionic应用程序开始,该应用程序将用于使用MapBox进行资产跟踪。这是我们想要做的https://blog.mapbox.com/how-to-do-asset-tracking-cb27ba2da5ab

的很好描述

第一步是找到一种解决方案,用于将位置和其他属性数据从移动设备推送到将侦听数据的流处理器。有谁知道我们可以为此使用什么服务或插件?

我们正在使用离子技术来开发移动应用

这是我们的新手,这是地图框支持如何描述该过程

  

Blockquote设备/硬件需要具有API服务的自有软件,该服务可以推送位置和属性数据。流处理器侦听此信息,并可以在其末端收集它(例如PubNub,Pusher等)。然后可以使用数据库存储此信息。所有这些都被认为是API网关,而Mapbox是您可以在其中查询或处理来自API网关的信息的最后部分,以便可以在地图上对其进行可视化显示。

1 个答案:

答案 0 :(得分:2)

PubNub's Publish Subscribe API will allow you to do this. In your Ionic app, you can do a PubNub publish after you create a free account and grab API keys. Below is the TS or JS code.

First sign up for a PubNub account (free up to 1 million transactions per month).

Pub/Sub

enter image description here

Installing the SDK in your Ionic 3 project

npm install pubnub --save

TypeScript or JavaScript

const pubnub = new PubNub({
    publishKey : 'your-publish-api-key-here',
    subscribeKey : 'your-subscribe-api-key-here'
});

// publish a JSON message to all subscribers
pubnub.publish({
    channel : 'my-awesome-channel-name',
    message: { hello: 'world' }
}, function(status, response) {
    // Handle error here
})

// any device in the world will receive publishes in realtime
pubnub.subscribe({
    channels: ['my-awesome-channel-name']
});

// do something with the message that you receive
pubnub.addListener({
    message: function(event) {
        // event.message === { hello: 'world' }
    }
});

If a subscriber device is not online while publishes occur, you can fetch past published messages using the PubNub Storage & Playback history API.

In case you need to log these messages to a database on your server, there is a guide for doing that with PubNub Functions:

https://www.pubnub.com/blog/the-right-way-to-log-all-messages-to-a-private-database/