Interface Veery.PoiUpdate
onPoiUpdate(Veery.Pois pois)
Interface Callback triggered when the backend computed new set of POIs.
Parameters
Param name | Type | Usage |
---|---|---|
pois | Veery.Pois | The whole set of POIs |
Returns
void
Usage / Example
Inline pattern
veery.requestPoiUpdate(new Veery.PoiUpdate() { @Override public void onPoiUpdate(Veery.Pois pois) { // // do whatever you need with the pois object // } });
Interface on activity pattern
The following example implement a Google Maps activity and update it when a POIs update happens
import android.location.Location; import com.roofstreet.android.veery.*; public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback, Veery.PoiUpdate { private final Veery veery = new Veery(this); private GoogleMap mMap = null; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); veery.serviceConnect(); veery.setApiKeySecret("SuPeRScrET12345789GhJ"); FirebaseApp.initializeApp(this); veery.setFirebaseToken(FirebaseInstanceId.getInstance().getToken()); // veery.activate(Veery.GEOPROFILE); // required for Predictions // Requires Android Veery 1.3.2 //veery.activate(Veery.BACKGROUND_GEOLOC | Veery.POINT_OF_INTEREST ); setContentView(R.layout.activity_maps); // Added by Google Maps // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); } @Override protected void onResume() { super.onResume(); veery.serviceResume(); veery.requestPoiUpdate(this); } @Override protected void onPause() { super.onPause(); veery.servicePause(); } @Override protected void onDestroy() { super.onDestroy(); try { veery.stopPoiUpdate(); veery.serviceDisconnect(); } catch (Throwable t) { } } @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { mMap.setPadding(200, 100, 0, 200); } }); } @Override public void onPoiUpdate(Veery.Pois pois) { if (mMap!=null) { mMap.clear(); JSONObject[] geoJsonData = pois.toGeoJSONArray(); if (geoJsonData!= null){ // JSONObject contains circles arround the POI for (int i = 0; i < geoJsonData.length; i++) { JSONObject object = geoJsonData[i]; GeoJsonLayer layer = new GeoJsonLayer(mMap, object); // Draw the circles layer.addLayerToMap(); Location loc = pois.toArray()[i]; LatLng latlon = new LatLng(loc.getLatitude(), loc.getLongitude()); // Draw a marker in the middle of the POIs zone mMap.addMarker(new MarkerOptions().position(latlon); } } } } }
Info
GeoJsonLayer classes are available on Google Maps API
User interaction
none
See also
getPois
Get last known list of POIs for that user.
requestPoiUpdate
Request for a callback event when a new set of POIs is computed by the Veery Backend.
stopPoiUpdate
Cancel the call to requestPoiUpdate.
Pois.toArray
Return an array of Location object.
Pois.toGeoJSONArray
Return an array of GeoJSON (circles around the POIs).
Pois.count
Return the amount of POIs known.
Pois.getWeight
Return the percentage of time spent at the specified POI.
PoiUpdate.onPoiUpdate
Callback triggered every time a new set of POIs is computed by the Veery backend.