Topic: How to determine the 2d pixel size of a 3d marker

Hi

We want a 3d marker to be always visible in the map area and we use an auto zoom function for this. As the position of the marker is set at its bottom, we want to zoom out, when the top of the marker leaves the top of the map, and not when its position (bottom of marker) leaves the map.

For this, we need to determine the 2d pixel height of the marker (which ist always constant).

Does anyone know how to do this?

Many thans.

Re: How to determine the 2d pixel size of a 3d marker

Hello.

You have many ways.
I would probably use OnlineMapsControlBase.GetScreenPosition to convert the marker coordinates to screen position, add half the height, and if Screen.width - screenPosition.y is less than some threshold, zoom out.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to determine the 2d pixel size of a 3d marker

Ok, many thanks for your answer.

This is exactly what I have done, but then the marker goes first completely out of the top of the map, before the auto zoom occurs. On the bottom of the screen, it works well, because the marker's position is set to the bottom of the marker, so it is still visible, before it goes out of the screen and the auto focus occurs.

If you mean by 'add half the height', add half the height of the marker height, then this was exactly my question. How do I get the marker height in pixels to be able to calculate half of the height?

Many thanks

Re: How to determine the 2d pixel size of a 3d marker

The best way is to hardcode it.
But if you really want to calculate the height dynamically, you can get Renderer of the marker instance, get the bounds from it, convert the corners to screen position, and calculate the height based on that.
Or instead of Renderer you can use Collider.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to determine the 2d pixel size of a 3d marker

We used the renderer and it works like a charm!

Many thanks.