您将如何将当前移动用户与 MobileFirst Browser simualtor 中的地理围栏区域进行比较。
例如:我创建了一个地理围栏区域,可以说是圆形。我清除了一个变量,因为我存储了诸如经度、纬度和半径之类的值。现在的任务是如何在移动地理位置(移动设备跟踪位置)时将此值与当前用户进行比较。
var myfence={longitude:2.2941741728805236,latitude:48.85817656827215,radius:100};
function getFirstPositionAndTrack() {
var geoPolicy = WL.Device.Geo.Profiles.LiveTracking();
geoPolicy.timeout = 60000; // set timeout to 1 minute
geoPolicy.maximumAge = 10000; // allow to use a position that is 10 seconds old
WL.Device.Geo.acquirePosition(
function(pos) {
// when we receive the position, we display it and start on-going acquisition
displayPosition(pos);
var triggers = {
Geo: {
posChange: { // display all movement
type: "PositionChange",
callback: function(deviceContext) {
displayPosition(deviceContext.Geo);
}
},
leftArea: { // alert when we have left the area
type: "Exit",
circle:{
longitude: pos.coords.longitude,
latitude: pos.coords.latitude,
radius: 100
},
callback: function() {
var msg="Left the area";
alert("Left the area");
AdapterCalling("Vinod",msg);
WL.Client.transmitEvent({ event: 'exit area'}, true);
}
},
dwellArea: { // alert when we have stayed in the vicinity for 3 seconds
type: "DwellInside",
circle: {
longitude: pos.coords.longitude,
latitude: pos.coords.latitude,
radius: 100
},
dwellingTime: 3000,
callback: function() {
var msg="You are Still in the Vicinity";
alert('Still in the vicinity');
AdapterCalling("Vinod",msg);
WL.Client.transmitEvent({ event: 'dwell inside area'}, true);
}
}
}
};
WL.Device.startAcquisition({ Geo: geoPolicy }, triggers, { Geo: alertOnGeoAcquisitionErr } );
},
function(geoErr) {
alertOnGeoAcquisitionErr(geoErr);
// try again:
getFirstPositionAndTrack();
},
geoPolicy
);
}