Code Monkey home page Code Monkey logo

Comments (7)

Spaxe avatar Spaxe commented on July 20, 2024 1

Thanks for this timely issue, @binakot. I ran into the exact same problem when upgrading from SDK 0.4.0 to 0.5.1.

Edit: I did a similar hack with TerrainFactory mesh generation complete, because I need to do expensive one-time raycasting to match terrain height, but only when it's loaded.

from mapbox-unity-sdk.

brnkhy avatar brnkhy commented on July 20, 2024

Hey @binakot!
It actually works but the problem is, it puts the object relative to the origin of the mercator projection system. So that lat/lng is most likely around those value (in meters) but the problem is, your world, or let's say your current tiles, are not.
Mesh generation stuff builds everything in relative position to prevent those huge numbers, so what you have to do there is to pass the position of you central tile instead of Vector2.zero in that call. I believe MapController class has the central tile reference in the current version so it should work if you simply use ReferenceTileRect.Center there.

from mapbox-unity-sdk.

david-rhodes avatar david-rhodes commented on July 20, 2024

@binakot MoveToGeocoordinate has been decoupled from MapController. Now, the method accepts additional arguments, such as refPoint and scale. For accurate placement, you need to pass these parameters in.

Try this:

	private void Update()
	{
            transform.MoveToGeocoordinate(Latitude, Longitude, MapController.ReferenceTileRect.Center, MapController.WorldScaleFactor);
	}

@brnkhy Can you shed some light on your future improvements with regards to removing these static references, please?

from mapbox-unity-sdk.

binakot avatar binakot commented on July 20, 2024

@brnkhy @david-rhodes Yes, it works when I pass MapController.ReferenceTileRect.Center and MapController.WorldScaleFactor in my test script. But I got NPE when I initialize objects of my data model on app running. It's not good idea to store it in static values.

from mapbox-unity-sdk.

brnkhy avatar brnkhy commented on July 20, 2024

@binakot static references will be removed soon and but still, you'll have to get the reference point from MapVisualization. In your case, you're simply doing your thing before the world is initialized and some critical properties are calculated/defined.
What we'll do though, is to create an event inside MapVisualization and then you'll be able to trigger your stuff to that event easily. Actually you can do that with the MapController class at the moment as well, just add an event and fire it right after ReferenceTile is set etc. That would solve your issue for now.

from mapbox-unity-sdk.

binakot avatar binakot commented on July 20, 2024

@brnkhy Okay, thanks. Atm I just added stupid coroutine with while loop until MapController will not initialized. And it works. I will add an event logic later probably, or just will wait next SDK release 🍸 Cheers!

from mapbox-unity-sdk.

david-rhodes avatar david-rhodes commented on July 20, 2024

Improved: #62

from mapbox-unity-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.