Updating previous GeoPoint in table

Hi Backendless,

First of all, sorry about my bad english :slight_smile:

I want to ask something that I learned from Backendless channel in Youtube about Backendless Geofence Monitoring in Action.

In the video, GeoPoint that saved to Backendless GeoPoint table is overwriting or updating the latest GeoPoint in certain duration.
That makes only one GeoPoint in ‘default’ category because its overwriting previous GeoPoint.

I try to do like that too. But my GeoPoint always making new Geopoint (not overwriting or updating) in ‘default’ category table and it makes a lot of new GeoPoint in that table.

Would you mind to check my code so it can be like video ? Thank You.

    final GeoPoint myLocation = new GeoPoint(0, 0);
    myLocation.addMetadata("VisitorType","CowboysFan");

    Backendless.Geo.savePoint(myLocation,new AsyncCallback<GeoPoint>()
    {
        @Override
        public void handleResponse (GeoPoint geoPoint){

        Iterator<double[]> iterator = coordinates.iterator();
        while (true) {
            if (!iterator.hasNext()) {
                iterator = coordinates.iterator();
            }

            double[] currentCoordinates = iterator.next();
            myLocation.setLatitude(currentCoordinates[0]);
            myLocation.setLongitude(currentCoordinates[1]);
            System.out.println(myLocation);

            Backendless.Geo.savePoint(myLocation, new AsyncCallback<GeoPoint>() {
                @Override
                public void handleResponse(GeoPoint geoPoint) {
                    System.out.println("aaaa");
                }

                @Override
                public void handleFault(BackendlessFault backendlessFault) {
                    System.out.println(backendlessFault.getMessage());
                }
            });

            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                System.out.println("got interrupted!");
            }
        }
    }

        @Override
        public void handleFault (BackendlessFault backendlessFault){
        System.out.println(backendlessFault.getMessage());
    }});


}

Regards,

Alvin from Indonesia

oh there are some missing code…

private static Timer timer;
private static Stack<double[]> coordinates = new Stack<double[]>();
static
{
    coordinates.push(new double[]{32.749690, -97.090800});
    coordinates.push(new double[]{32.749790, -97.091800});
    coordinates.push(new double[]{32.749590, -97.092100});
    coordinates.push(new double[]{32.749490, -97.090800});
    coordinates.push(new double[]{32.749590, -97.090900});
    coordinates.push(new double[]{32.749690, -97.091100});
    coordinates.push(new double[]{32.749790, -97.091200});
    coordinates.push(new double[]{32.749890, -97.091300});
}

If you need to update an existing geo point, you need to make sure the GeoPoint object you’re updating has the objectId property set.

Thanks Mark, I wil try to do that.