Topic: Getting Marker Positions as a Vector3


I have been using OnlineMaps for some dev work and I am hoping someone can assist me with getting the location of a OnlineMapsMarker3D marker ( I have added many markers to the map with altitude). I create many markers on the map with altitude and I want to get the markers world position and not where it is living on the map. I want to connect these markers with a lineRenderer ( not draw on the map ) and I know how to do it fine outside of OnlineMaps..but the issue is that as soon as I add the marker to the map and start to query for its position I cannot get the actual position. I have looked at MARKER.instance.transform.position and MARKER.transform.position but things do not appear to pass back the actual transform of the OnlineMapsMarker3D.

Inside of a loop I am doing:

OnlineMapsMarker3D fishLoc = OnlineMapsMarker3DManager.CreateItem(nLng, nLat, bearingGameObject);
                fishLoc.altitudeType = OnlineMapsAltitudeType.absolute;
                fishLoc.altitude = showBelowWater ? val.z : -val.z;
                fishLoc.sizeType = OnlineMapsMarker3D.SizeType.meters;
                fishLoc.scale = 100f;

..then I am trying to get the world position of the marker I just added ( something like):

vector3 actualWorldLoc = fishLoc.transform.position; // or fishLoc.instance.transform.position

..the issue I am having is that it is not giving me back the actual position of the markers as is noted in the inspector when I look at the marker on the 'marker' section of the map. The inspector values all seem accurate but I cannot get the same values via code when I am creating the items on the map.

Hopefully that all makes sense. ANy help appreciated!

Re: Getting Marker Positions as a Vector3

..also worth noting I did look at the "getPosition" possibilities but I was only seeing vector2 return values and nothing. I also created ( from :

public Vector3 GetWorldPositionOfMarkerWithElevation(double lng, double lat, double heightVal)
        double mx, my;
        GetPosition(lng, lat, out mx, out my);

        mx = -mx / map.width * sizeInScene.x;
        my = my / map.height * sizeInScene.y;

        float y = (float)heightVal;

        Vector3 offset = transform.rotation * new Vector3((float)mx, y, (float)my);

        return map.transform.position + offset;

...and while this is not accurate it does render lines which are too deep ( I am sure my scaling needs work!!) . This work was based off of  public Vector3 GetWorldPositionWithElevation(double lng, double lat, double tlx, double tly, double brx, double bry).

Re: Getting Marker Positions as a Vector3


Marker positions are not updated immediately, but when the map is redrawn.
You need to call marker.Update to force a marker to update the position or use OnlineMapsControlBaseDynamicMesh.GetWorldPositionWithElevation(double lng, double lat, float altitude) to get the position in the scene, without creating markers. … 341347139b

Kind Regards,
Infinity Code Team.

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

Re: Getting Marker Positions as a Vector3

Ah. Yes I called update and things worked as expected. I think I am a couple of versions out and I do not have the GetWorldPositionWithElevation(double lng, double lat, float altitude)..but I am always afraid to upgrade packages of things when things are mostly working ( hence going with the MARKER.update();

thanks for the help. Greatly appreciated!! I should have known that an update/refresh would do the trick!