Is it possible to insert external values to the location sensor?

Is it possible to input values ​​from an external device to the location sensor? The case would be to take the location and orientation from an external gps antenna and for the location sensor to take those values ​​and update its location.

No.

You can use an external device's location information and plot that data to a Map component map.

What you can do with the LocationSensor is described in LocationSensor and provides the documentation. Using the Location Sensor explains how the component works.

It appears you just want to plot the external location information on a map, so port the coordinates from the external device to the Map component Map . You probably would use
PanTo( latitude , longitude , zoom ), the Block pans the map center to the given latitude and longitude and adjusts the zoom level to the specified zoom.

The location sensor gives me automatic marker orientation (shows where the arrow is pointing). On the other hand, in the map components, if I use a marker to set the external values, I don't have the option to add the rotation to determine in which direction the marker is pointing (assuming that we set an arrow image to the map marker) . the objective is to be able to generate a marker that moves and changes its orientation based on the external data of the GPS antenna. I don't want to rotate the map, not that function, I want to rotate the marker)

You asked essentially the same question here :slight_smile: How do I rotate the map marker (draw a line on the map at an angle)? and got a workable solution.

The contol does not provide that option however, the final posts describe how to rotate the marker. The advice doesn't suggest rotating the map although that could be done too. See Tim's post.. Direction to point the custom marker must be provided by your external hardware and you must use that information to orient the marker. Tim even provides an aia. Just plug in the 'direction' into his simple algorithm. I think you need to re-read the last posts again. Did you try his example?

To determine the direction using Blocks, if not provided by you external hardware, you need to note the actual location now and calculate a bearing from the previous location.

1 Like

Yes, it is something similar, but I was looking for a different option. Tim's thing works perfect but only for Android version 8.1.0, for the rest it doesn't work as I wish.

Which is odd, since I built and tested on Android 10....

1 Like

I tested Tim's routine on Android 4.2.2, Android 5.1 and Android 8.1. The custom map marker rotates only on my Android 8.1.

As far as I can tell, this is possibly an issue with the Custom Marker on the Map Component that does not allow redisplay of a Custom Marker on those platforms. The behavior may be a bug in the Custom Marker (ImageAsset). Perhaps a Custom Marker requires resources available on in higher Android versions that are not unavailable in the systems on lower versions. I cannot test Android 6 and 7 or Android 8.1+. I do note the technique works very well with 8.1. :slight_smile: I only tested the rotation using Companion on the lower Android devices...the result might be different if tested using a compiled app.

What do you think @ewpatton ? Tim's example uses a png arrow image. Perhaps lower Android versions require a svg vector graphics image?

What is strange is that in version 10.0 it does not work either. I tried on a device with that version and was unsuccessful. only 8.1 is the one that walked.

Buy this extension that allowed adding a marker with rotation: https://atomdeveloper.com/2020/11/16/custom-marker-extension-for-google-maps/ but it only works for the Google map and not for the component map provided by app inventor. But that extension would be a solution I am looking for.

I'm processing this thread, so please let me reiterate what I interpret are the underlying issues:

  1. The built-in mechanism for drawing the user location also shows orientation. @Info_Montetch is interested in being able to do this with data from something other than the LocationSensor component.
  2. Markers do not have a mechanism for orienting them to anything other than top = north.
  3. Only the first ImageAsset is drawn for a Marker.

Did I miss anything?

@ewpatton @SteveJG The difference is that if we use the marker, it allows us to place the location with the external data of the antenna, but it does not allow us to represent the orientation. On the other hand, with the location sensor it allows us the sense of orientation, but it does not allow us to set the external values ​​of the gps antenna.

The solution that @TIMAI2 gave me, to generate a rotated image (with imageAsset) and then set it to the marker is excellent, but we have problems according to Android. On my 8.1 device it worked, but in other versions the marker image is only rotated once and on other occasions it does nothing. So it is not an acceptable option at the moment until you know the problem.
Regarding this solution, I ask: Is it perhaps a problem with the version of MIT App Inventor that I have? I currently use an offline version. (It does not have a specific version, it is only called Ai2OfflineServer)

I'm not sure, but MIT does not provide any offline versions nor do we support them. We only provide support for the online version as hosted at MIT.

  • Which Android OS did you check? 4.2, 5, 6, 7, 10, 11?
  • When you checked if the image rotated, did you test Tim's aia exactly as he coded or are these tests using the input from you external gps system to rotate the image. It would help if you shared your code showing this part of your app.
  • How does the gps data arrive at your Android (Bluetooth ?). The issue could be an issue with respect to the data stream from your external gps is causing problems. Perhaps the data is arriving too fast to elicit a direction change.
  • are you testing using Companion or are you compiling the apk and loading it to your test devices?

Perhaps.
Your Ai2OfflineServer uses a version of App Inventor code. Currently the most up to date version of App Inventor online is nb186a which should be used with Companion 2.60 or 2.60 u. Is the offline third party software this one
AI2Offline - Browse Files at SourceForge.net ? It appears that software is currently using nb183c which is old. You are using that version probably unless you uploaded the software very recently... there appears to be a more recent version that was posted several days ago on SourceForge.

Have you tried the App Inventor main online server at all as a test? What happens?

Yes, check out several. Currently the 4.4, 7 and 10 did not work for me, but if I work now in the 9. I am going to collect more recruiters to try.

I use exactly the apk of tim, I only changed the path where the imageAsset would be saved.

I just tried the tim apk without any extra bluetooth data. I press the rotate button and manually add the degrees for it to rotate.

The topic of the versions is something that I have yet to try. So possibly try the one you sent me or the online mode to see what happens.

I'll keep you informed!
Thank you very much!

Yes, it is similar to the one in the link but I don't remember which one it is, nor which version either, because I have it for more than a year.

Thank you very much!