Topic: online maps unity3d zoom problems

Hi,
when using unity3d with online maps, i can add an entity to the map to a certain point, but when i zoom-out or zoom-in the location of the object is changed, and just moving to anouther palce on the map.
when returning to the initial zoom level, the object returns to place.

should i be doing anything special?

my code:

    OnlineMaps api = OnlineMaps.instance;
    public Vector3 HPosition()
    {
        float Lat = model.Lat;
        float Lng = model.Lng;
        float Rad = model.Radius ;
        Vector3 position = OnlineMapsTileSetControl.instance.GetWorldPosition(Lng, Lat);
        position.y = -0.70f;
        return position;
    }
    public Quaternion HRotation()
    {
        float heading = 90;
        return Quaternion.Euler(0, heading, 0);
    }
    private void Update()
    {
       
        this.transform.rotation = HRotation();
        this.transform.position = HPosition();
        float k =Mathf.Pow(2,9);
        float scale = Mathf.Pow(2, api.zoom)/k;
        this.transform.localScale = scale * Vector3.one * model.Radius/15f;
    }

Re: online maps unity3d zoom problems

this is a marker ? probably because you are explicitly setting the position of the transform directly in Update.

instead use marker.SetPosition(lng,lat), then let OnlineMaps position the marker/transform etc automatically for you.

Re: online maps unity3d zoom problems

braden wrote:

this is a marker ? probably because you are explicitly setting the position of the transform directly in Update.

instead use marker.SetPosition(lng,lat), then let OnlineMaps position the marker/transform etc automatically for you.

I am not using markers.. i am using prefabs (of cars for example) and the cars are constantly moving, depending on information from the server(pooling every 3 seconds).

can i set a 3d prefab as a marker and then update the location of it constantly?

Re: online maps unity3d zoom problems

Yes.
Fragment from my project:
New marker:
Vector2 markerPosition = new Vector2(jsonData.items  .location.lng, jsonData.items  .location.lat);
marker = control.AddMarker3D(markerPosition, markerObjectPrefab);
marker.range = new OnlineMapsRange(minZoom, maxZoom);
marker.tags = tagInfo;
marker.OnClick += OnMarkerClick;
marker.scale = MarkerScale;
marker.OnPress += OnMarkerPress;
marker.customData = customMarkerData;
marker.OnRelease += OnMarkerRelease;
marker.OnRollOut += OnRollOut;
if (jsonData.items  .self == true){
    marker.OnLongPress += OnMarkerLongPress;     
}
MarkerRotation:
if (OnlineMaps.instance.zoom <=13){
    marker.rotation = Quaternion.Euler(-90,0f,0f);
}else{
    marker.rotation = Quaternion.Euler(MarkerAngle,0f,0f);
}

marker movement:
marker.SetPosition(lng,lat);

All info you can find at:
http://infinity-code.com/doxygen/online … ac75c05eb0

Re: online maps unity3d zoom problems

Hello.

As braden and zuicis answered you above, you can use 3D markers.

For me, the original problem is more interesting.
Based on your code, I made a test script (attached).
Video:
https://www.dropbox.com/s/jn9wbun3uj126 … 1.mp4?dl=0
In my opinion, this looks normal and expected.
If possible, make a small video that demonstrates the problem.

Kind Regards,
Infinity Code Team.

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

Re: online maps unity3d zoom problems

Oops. Forgot to attach the script.

Post's attachments

Attachment icon TestPrefabMoving.cs 1.18 kb, 362 downloads since 2017-08-02 

Kind Regards,
Infinity Code Team.

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