Start a new topic

get screen coordinate (x, y) of ar object, android javascript sdk

get screen coordinate (x, y) of ar object, android javascript sdk


I want to build a kind of customized radar like this (attached). The green pointer indicate the location of POI relative to user. How i get the screen coordinate (x,y) of ar object that rendered so i can move the pointer based on the position of ar object in the screen ?



Hi there!

It is not possible to query the on screen coordinates of redered objects.

for your scenario you may inject magnetometer values from native into JS every second. That way you can calculate the direction of the POI relative to the user's lat/lon in your JS code and align your "radar" accordingly.

hope that helps.



thanks for the reply. I have two question :
(1) Based on your suggestion, what kind of direction value that i need to align "my radar"? since "my radar" was coded in native so it needs the changing of its X coordinates.
(2) Is it possible to freeze the Y of 2D ar object? for example i freeze it at the top of the screen, but it still moving on X axis.




Understood, implementing your custom "flat radar" might be quite tough then.

I recommend you to have a look at the provided AR.Radar component instead. You may then define drawables.radar of every POI to let it appear in the radar.
Even the direction indicator is a feature offered by AR.GeoObjects, check out drawables.indicator. You can then easily show e.g. a small arrow that points to the POI that is not visible.

best regards

thanks for the reply,

indicator only shows when the POI was not on the screen, but is there a way that make the indicator always shows on the screen?

And how could i get and set the indicator's attribute? e.g. its offsetX, offsetY or else.



Indicators are solely shown when POI is out of view, if you want to show it also when POI is on screen you can adjust your camdrawable-set.

Once Indicator asset is defined you do not need to change any values. use offsets just to define "the pointer of the arrow/indicator"

what do you mean by "you can adjust your camdrawable-set", i mean could you put it at a sample code please?

the reason i want to set a offsetY value was, i want the indicators always stay on top of the screen, its only move right-left


Andreas Hauser "It is not possible to query the on screen coordinates of redered objects."

That would be great if this information could ba available on the next version of the SDK ! :-)


The "get screen coordinate (x, y) of ar object, for javascript sdk is critical to our project.

Please let us know if this feature is available in SDK 5


Login or Signup to post a comment