Problem with PolylineOptions

11 posts / 0 new
Last post
AdiM
Problem with PolylineOptions

I’m new in this part of development.

I tried your example “Put a Polyline on the Map” but there is no poly showed in my map. I have set the position to my location.


MQBrianCoakley
If you set the map position
If you set the map position to one of the polyline coordinates do you see it? Or if you use your position as one of the polyline coordinates do you see it?

AdiM
Oh, i used Polygon... With

Oh, i used Polygon... With polyline it works, sorry

but in this case, i shuld get a box-like thing, should, n I?

Ather question, sometimes, when i use zoom > 15 (also manualy on map) I get this error with crash:

A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x164 in tid 16660 (RenderThread)
Application terminated.


MQBrianCoakley
There are both polyline and
There are both polyline and polygon, depending on what you're after. If you're using polygon, you should get a filled shape rather than a line.   Do you get the error in an emulator, device, or both?

AdiM
I work with Android Studio

I work with Android Studio with a real smartphone connected for my tests.


kevin.colin
Hey AdiM, what device and

Hey AdiM, what device and android version are you testing on? Also, could you clarify if this only happens occasionally and on a pinch-to-zoom gesture?

Thanks!


AdiM
Yes it happens occasionally.

Yes it happens occasionally. I work on a Motorola Moto G2 device with Android 5.0.2. It also happens by calling:

mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 17));

In my test app I inserted follows code mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15));

After I set zoom level up to 15, I get message E/mbgl: {Map}[OpenGL]: stencil mask overflow repeatedly in my log frame. Could it be relevant?


kevin.colin
The stencil mask overflow is

The stencil mask overflow is something we are aware of and are working on removing. We haven't been able to reproduce the zoom crash however. We'll continue looking at ways to reproduce it. Is there more info you can provide? For example, do you start off at a certain zoom level and location and then call `mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 17));` ? If you could provide a code snippet that would be even better. 


AdiM
There I have my source code

There I have my source code MainActivity.java

package ch.example.am.weginsbuero;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.view.View;

import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapquest.mapping.constants.Style;
import com.mapquest.mapping.maps.MapView;
import com.mapquest.mapping.maps.MapboxMap;
import com.mapquest.mapping.maps.OnMapReadyCallback;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends Activity implements View.OnClickListener {
    private MapboxMap mapboxMap;
    private MapView mapView;
    private boolean traceIt = false;
    private List<Location> locations = new ArrayList<Location>();
    private WegHandler wegHandler = new WegHandler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        findViewById(R.id.start).setOnClickListener(this);
        findViewById(R.id.stop).setOnClickListener(this);

        mapView = (MapView) findViewById(R.id.map);
        mapView.onCreate(savedInstanceState);

        startService(new Intent(MainActivity.this, PathRecordService.class)); // Starts the GPS-Services

        mapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(MapboxMap mapboxMap) {
                MainActivity.this.mapboxMap = mapboxMap;
                mapView.setStyleUrl(Style.MAPQUEST_SATELLITE);                  // Darstellung mit Satelittenbild
                MainActivity.this.mapboxMap.setMyLocationEnabled(true);         // Zeichnet den aktuellen Standort
                MainActivity.this.mapboxMap.getUiSettings().setZoomControlsEnabled(true);
                MainActivity.this.mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18));     // CRASH ==> zoomTo(14) works

                // next don't gives an effec...!
                mapboxMap.setTrafficFlowLayerOn();
                mapboxMap.setTrafficIncidentLayerOn();

            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        PathRecordService.setUpdateHandler(wegHandler);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.start) {
//            startService(new Intent(MainActivity.this, PathRecordService.class));
            PathRecordService.setUpdateHandler(wegHandler);
        }
        if (v.getId() == R.id.stop) {
            stopService(new Intent(this, PathRecordService.class));
        }

        if (v.getId() == R.id.trace) {
            traceIt = !traceIt;
        }
    }

    private void moveView() {
        if (locations.isEmpty())
            locations = PathRecordService.getLocations();

//        mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(locations.get(locations.size() - 1)), 17));
        if (!locations.isEmpty())   // Wenn immernoch leer, GPS noch nicht bereit
            mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(locations.get(locations.size() - 1))));
    }

    private class WegHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
            Log.v("handleMessage", "Message received");

            locations = PathRecordService.getLocations();
            moveView();
        }
    }

}


AdiM
... and my source code

... and my source code PathRecordService.java

package ch.example.am.weginsbuero;

import android.Manifest;
import android.app.Service;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

/**
* Created by AM on 23.09.2016.
*/
public class PathRecordService extends Service implements LocationListener {
public static final int GPS_IDLE = 0;
public static final int GPS_RECORTING = 1;
public static final int GPS_LOCATING = 2;
private static Handler updateHandler;
private static List<Location> locations = new ArrayList<Location>();
private LocationManager locationManager;

public static List<Location> getLocations() {
List<Location> location = new ArrayList<Location>(locations);
locations.clear();
return location;
}

public static void setUpdateHandler(Handler updateHandler) {
PathRecordService.updateHandler = updateHandler;
}

@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public void onCreate() {
super.onCreate();

locations.clear();
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
} else {
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
locations.add(locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER));
}
}

@Override
public void onDestroy() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
locationManager.removeUpdates(this);
}
super.onDestroy();
}

@Override
public void onLocationChanged(Location location) {
if (location == null) {
return;
}
locations.add(location);
if (updateHandler != null) {
updateHandler.sendEmptyMessage(1);
Log.v("MY CURRENT LOCATION", "Latitude = " + location.getLatitude() + " Longitude = " + location.getLongitude());
}
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {

}

@Override
public void onProviderEnabled(String provider) {

}

@Override
public void onProviderDisabled(String provider) {

}
}


AdiM
Description:

Description:

In my Panel I use MapView called map and buttons for start, stop and trace. But you dont have to press anythin just wait.

Thanks for help