Why doesn't LocationDisplay.setCourseSymbol() work.

686
3
12-21-2019 01:34 PM
NathanMellor
Occasional Contributor

The following happens after I call LocationDisplay.setCourseSymbol

NOTHING.


You are still using the same symbol that you always were.

I can even verify this in the debugger.

When setting up attributes for LocationDisplay, I call setCourseSymbol.

I call getCourseSymbol just to make sure it is there. Yep.

Later, after calling LocationDisplay.startAsync(), I want to check it.

I call getCourseSymbol.

It returns your default symbol as if nothing had ever happened.

WHY?

0 Kudos
3 Replies
JoseBanuelos
Esri Contributor

Hello Nathan,

According to the LocationDisplay documentation, the setCourseSymbol() method can be used if isCourseSymbolOnMovement() is true. This boolean is set to true "when location updates indicate the device is moving. If no course information is available, the default symbol will be used instead". This means that in order to view the new symbol you set, the device needs to be moving, or appear to be moving (if using a gps spoof app).

As long as you call the setCourseSymbol() method after calling LocationDisplay.startAsync(), and your device/emulator is moving (or simulates movement), the you will be able to see the symbol you set.

I used the display-device-location sample app to test and confirm this. Here is the source code I added to test:

//MainActivity.java

//code added under the case 1 switch statement for the mSpinner.setOnItemSelectedListener(...)

mLocationDisplay.startAsync(); //original code from sample app
SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CROSS,
Color.RED, 12);
mLocationDisplay.setCourseSymbol(simpleMarkerSymbol);

When I turned off the gps spoof app, the symbol would not display. Once I started the spoof app to simulate movement from the emulator/device, the symbol appears. Here is a screenshot below:

Regards,

Jose

NathanMellor
Occasional Contributor

As long as you call the setCourseSymbol() method after calling LocationDisplay.startAsync(), and your device/emulator is moving (or simulates movement), the you will be able to see the symbol you set.

 

The part about calling it after calling LocationDisplay. startAsync() is not mentioned in the documentation.

I tried calling setCourseSymbol at the beginning, at the same time I call things like setNavigationPointHeightFactor and setInitialZoomScale

After all LocationDisplay can be started and stopped multiple times.

But I guess you have to set it everytime you call startAsync, or the change gets overridden.

0 Kudos
JoseBanuelos
Esri Contributor

Hello Nathan,

If you call LocationDisplay.startAsync() inside the LocationDisplay.addDataSourceStatusChangedListener(), you will only have to call setCourseSymbol() once.

if (dataSourceStatusChangedEvent.isStarted()){
   mLocationDisplay.startAsync();
   SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CROSS,
      Color.RED, 14);
   mLocationDisplay.setCourseSymbol(simpleMarkerSymbol);
   return;
}

This even listener gets called whenever there is a change in the status of the location data source.

Regards,

Jose

0 Kudos