Pavan Alapati
Pavan Alapati

Reputation: 635

How to get "Entry" and "Exit" message on geospatial analytics in IBM bluemix

I am working on IBM Bluemix IOT application.I created devices and I am getting maps successfully. I created geospatial analytics service in bluemix also. In maps I am able to create geofence. When car enters geofence it is successfully giving entry message. But when car exits ,its not showing exit message.

Subscriptions.geoAlerts = new Subscription(window.config.notifyTopic, function(msg) {
        if (!msg.destinationName.match(window.config.notifyTopic)) { return; }
        try {
            var data = JSON.parse(msg.payloadString);
            console.log(data);
            var id = data.deviceInfo.id;
//JR: Custom GEO notification
            //var text = data.eventType;
            var text = "Entry";

            var fgColor = "white"; 
            var bgColor = "rgba(0,0,0,0.8)"; 
            var duration = 2000;

            var c = demo.getCar(id);
            if (c) {
                c.addOverlay(text, duration, bgColor, fgColor);
            }
            /*
            var id = data.id;
            var text = data.text;
            var fgColor = data.fgColor || "black"; 
            var bgColor = data.bgColor || "rgba(255,255,255,0.9)"; 
            var duration = data.duration || 3000;

            var c = demo.getCar(id);
            if (c) {
                c.addOverlay(text, duration, bgColor, fgColor);
            }
            */
        } catch (e) { console.error(e.message); }
    });

the above MQttClient.js I am using . Can any one give me suggestions highly appreciated. Thanks in advance

Upvotes: 0

Views: 82

Answers (2)

Mike B
Mike B

Reputation: 46

In addition to Paul's answer... if you haven't done so, make sure to specify:

"notifyOnExit" : "true",

on your call to the addRegion API.

Upvotes: 1

Paul Allen
Paul Allen

Reputation: 41

The code as shown will display "Entry" for all events received including entry and exit events (as well as "hang out" events if the monitored region is configured for hangout detection). You should be using data.eventType as shown in the commented line of code (line 8) above.

Upvotes: 0

Related Questions