how to getUiSettings() in MAPBOX V10 Java - mapbox

guess it is simple yet I cannot achieve it. I want to get the UiSettings for Mapbox
In build.gradle
implementation 'com.mapbox.maps:android:10.10.0'
implementation 'com.mapbox.plugin:maps-scalebar:10.10.0'
implementation 'com.mapbox.plugin:maps-compass:10.10.0'
implementation 'com.mapbox.plugin:maps-logo:10.10.0'
implementation 'com.mapbox.plugin:maps-core:10.10.0'
in Activity onStart()
mapView = findViewById(R.id.mapView);
mapView.onStart();
mapView.getMapboxMap().loadStyleUri(Style.OUTDOORS);
mapView.getMapboxMap().setNorthOrientation(NorthOrientation.UPWARDS);
mapView.getMapboxMap().setCamera(new CameraOptions.Builder()
.center(Point.fromLngLat(11.0, 52.0))
.zoom(15.5)
.build());
I can bring up the mapView, use the new easeTo methods etc. to update the camera yet I am unable to get the UiSettings as in (earlier versions) with .getUiSettings.
(I am also struggling with modifying the Scalebar and bringing up the compass. Obviously I am not understanding how to use these features in Mapbox v10.)
Thanks for your time and help. This is my first post, hoping it comes out well :-)
Best,
Thomas
failing
mapView.getMapboxMap().getUiSettings()
ScaleBarSettings ss = new ScaleBarSettings();
ss.setEnabled(true)

Related

ARAnchorManager.HostCloudAnchor(anchor) returns null — ARCore Extensions for AR Foundation

Calling ARCloudAnchor cloudAnchor = manager.HostCloudAnchor(anchor) gives null for cloudAnchor (where manager is of type ARAnchorManager and anchor is of type ARAnchor). I have the API key set up for ARCore Extensions with the GCP server. Help is much appreciated.
Maybe your feature map quality is not good. Try to call manager.EstimateFeatureMapQualityForHosting(GetPoseCamera()) to check the quality
INSUFFICIENT: it is not good enough to resolve cloud anchor later (host anchor can be failed with this quality and you may receive NULL for cloud anchor) -> try to move device around object.
SUFFICIENT: it is okay
GOOD: it is good
Note: You have to define GetPoseCamera() function. (it is easy, just includes position and rotation of camera)
Took me a while, but I fixed this.
Even though the ARCore Extensions sample gave cloudAnchor.cloudAnchorState == CloudAnchorState.Success immediately when calling manager.HostCloudAnchor, I got cloudAnchor.cloudAnchorState == CloudAnchorState.TaskInProgress which made cloudAnchor == null give true. I needed to loop until the state was Success (which took about 5 seconds each time). After the wait, the anchors are hosted without a hitch.

Remove Cesium's Camera Move Event Listener

I have the following event listener:
viewer.camera.moveStart.addEventListener(function(removeextra) {
// the camera started to move
clearoriginal();
});
viewer.camera.moveEnd.addEventListener(function(addback) {
// the camera stopped moving
getresults();
});
How can I remove these event listeners? I do not know the syntax.I tried with the following it does not work.
viewer.camera.moveStart.removeEventListener(removeextra);
viewer.camera.moveEnd.removeEventListener(addback);
I looked into Cesium and I think you might rewrite them like this
viewer.camera.moveStart.addEventListener(clearoriginal);
viewer.camera.moveEnd.addEventListener(getresults);
// then to remove
viewer.camera.moveStart.removeEventListener(clearoriginal);
viewer.camera.moveEnd.removeEventListener(getresults);
viewer.camera.moveEnd.removeEventListener('click',
getresults,// pass the method which you add
false
);
addEventListener() and removeEventListener() are not present in older browsers. You can work around this by inserting the following code at the beginning of your scripts, allowing the use of addEventListener() and removeEventListener() in implementations that do not natively support it. However, this method will not work on Internet Explorer 7 or earlier, since extending the Element. a prototype was not supported until Internet Explorer 8.

what is the equivelant of get_global_pos from version 2.0 in 3.0?

I want to make a turret that is shooting lazers and i watched a tutorial on it. The person in the video used (scenename).position(get.node("Position2D").get_global_pos()) in order to spawn a projectile on the potition 2d. When i run this code, the game freezes and the debugger says "Invalid call. Nonexistant function 'get_global_pos' in base 2D". In the comments someone said that the tutorial is using 2.0 godot and that in 3.0 you dont use get_ and instead of pos you put potition, so i tried changing get_global_pos to global_position but it didnt work. i am very new to this and if you want any further information please let me know
As you already found out, global_position is the equivalent to get_global_pos.
The difference is, that global_position is no function but a member.
So instead of:
(scenename).position(get.node("Position2D").get_global_pos())
you have to write:
(scenename).position = get.node("Position2D").global_position

iRobot Create not returning sensor data

I am trying to stream sensor data from the iRobot Create. I get tuple out of range errors when I try
bot.stream_sensors(somenumber) and bot.poll_sensors(somenumbers). Whenever I input bot.sensors, I just get an empty array {}. I have even tried sending bot.sensors while pushing in on the bump sensor, still getting an empty array. I am connected to the bot through the Serial port with a serial-to-usb converter on my side. The only code before trying to get the sensor data is
import openinterface
bot = openinterface.CreateBot(com_port="/dev/ttyUSB0", mode="full")
Does anyone have an idea of how to solve this issue? Everywhere else just uses stream_sensors(6) and it seems to work fine.
P.S. I posted a question similar to this topic not too long ago, but no one responded. Not trying to spam, but now I have a more clear question and what the apparent-problem is so I thought I would try again.
I downloaded openinterface.py from this site: which included some sample programs. I'd suggest you take a step back, try the sample code, try to find other, more sophisticated, sample code and play with that first before moving on to your real code. You may be missing a step somewhere.
I may be a bit late to answer this, but for reference purposes. Directly controlling the iRobot is simplified greatly by using
Pyrobot.

How to simulate a user driving a route in a MKMapView?

I need to simulate how my application will look when a user is driving around for a demo. I have a MKMapView, how can I simulate the look of a user driving around which will use the map.userLocation functionality, which obviously will not be available in the demo.
Thanks!
No way to simulate in iPhone simulator. You'll need to load it onto your device and move around.
Well I got something going, I just did essentially this
- (void)moveIcon:(MKAnnotationView*)locationView toLocation:(CLLocation*)newLoc
{
LocationAnnotation* annotation = [[[LocationAnnotation alloc] initWithCoordinate:newLoc.coordinate] autorelease];
[locationView setAnnotation:annotation];
[map setCenterCoordinate:newLoc.coordinate animated:YES];
}
Then I call this guy in a loop between all of my vertices with a slight delay. Works quite qell.
I'm not an iPhone dev expert, but how does the map view receive the coordinates? If it's through a function that calls the CoreLocation API, could you possibly just write a function that randomly generates longitude and latitude values at a certain time interval and have your map view pull the coordinates from there instead? Just a thought.
You could also check out iSimulate which claims to be able to simulate several features only available on the iPhone in the iPhone simulator include CoreLocation. I have not tried this myself so your mileage may vary.
In order to simulate driving you'll need to establish 2 basic functionalities:
Reading CLLocations from an archive (which you'd log during the drive test with a device). Ideally you'll do this based on the timestamps on the locations, i.e. reproducing the exact same location updates which were received during the drive test.
Updating your MKAnnotationView's position on the map based on the locations read from log.
For part 1, take a look at CLLocationDispatch, a handy class which provides archiving/unarchiving of CLLocations and dispatches them to one or more listeners (using CLLocationManagerDelegate protocol).
For part 2, take a look at Moving-MKAnnotationView.
I found a better way would be to subclass MKUserLocation:
class SimulatedUserLocation: MKUserLocation {
private var simulatedCoordinate = CLLocationCoordinate2D(latitude: 39, longitude: -76)
override dynamic var coordinate: CLLocationCoordinate2D {
get {
return simulatedCoordinate
}
set {
simulatedCoordinate = newValue
}
}
}
Then add it as an annotation mapView.addAnnotation(SimulatedUserLocation()). (You might also want to hide the real location first mapView.showsUserLocation = false)
iOS would render the annotation exactly like the real user location.
dynamic is used on the property so that changing coordinate triggers KVO and moves it on the map.
The answer is NO. Then, how about adding an abstraction layer between your code and MKMapKit? You can do xUnit tests for your objective.