mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

Observations when upgrading to 1.2 from 1.1

Open Alexphauge opened this issue 9 years ago • 8 comments

Well, we finally took the plunge onto the 2017 Unity platform because we needed to keep Mapbox up to date with all its goodies you people are bringing into it.

First of all, just some design questions: (1) Any reason AbstractMap.cs methods TileProvider_OnTileAdded and TileProvider_OnTileRemoved are not protected virtual so they can be overridden in the specific implementation? (We've changed this in our local files because we keep some additional lists of each tile)

(2) A simple helper function we keep including in every build is in AbstractMapVisualizer (earlier just MapVisualizer), called GetUnityTileFromUnwrappedTileId(UnwrappedTileId tileId) { return _activeTiles[tileId]; } - I'd like to know if this goes against your designs of certain data flows in your SDK, but right now it's something we're using to reference each tile through the abovementioned (1).

Second, that dynamic zoom is amazing for our upcoming feature requirement (why we actually upgraded to 2017 and newer Mapbox 👍 ) - any guesses about when all the current branches/improvements will be merged onto develop?

Thanks again for a great SDK! - I'll probably add more things to this thread if I find any. :)

Alexphauge avatar Nov 16 '17 13:11 Alexphauge

This is probably an artifact of how we've been doing things earlier, but it seems that AbstractMap requires a latLonSplit value because otherwise, it will throw an error like below.

FormatException: Invalid format. System.Double.Parse (System.String s, NumberStyles style, IFormatProvider provider) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Double.cs:209) System.Double.Parse (System.String s) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Double.cs:180) Mapbox.Unity.Map.AbstractMap.Start () (at Assets/Mapbox/Unity/Map/AbstractMap.cs:132)

We use another class, an implementation of IMapController, should we try and move away from this for future compatibility?

(Edit about the above, just in case anyone else gets in the same problem: ... Just disable the great little boolean tick box out on the implementation of AbstractMap in the editor called "Initialize on start" and all the above mentioned isn't a problem anymore)

Also, for some reason we're creating duplicate tiles right now. Any idea why? (I've yet to delve into the matter, but if you already had experience handling it, I'd appreciate hearing it 👍 )

Alexphauge avatar Nov 17 '17 13:11 Alexphauge

@Alexphauge thanks a lot for the feedback!

  1. I don't think there's a reason for that, probably only because we never needed it so far. I personally cannot see a problem with making stuff virtual. It suits an SDK better.

  2. Again this is totally fine and we probably should implement this as well. MapVisualizer is the core map object so it feels perfectly fine to query Map for what's in there and not. Just like (1), only reason it's not there is that we haven't had a case for it and we were waiting for developer needs and use cases to shape such stuff up.

AbstractMap is just a script we use for demos, it's like an interface for your inputs to MapVisualizer. So you should be able to remove that all together and make your calls directly to MapVisualizer if you want as well.

Can you elaborate the duplicate tiles thing? I never noticed something like that and might be an important issue (waste of memory and probably game object creation).

brnkhy avatar Nov 17 '17 15:11 brnkhy

👍 for the feedback. I agree with @brnkhy that we can implement 1 and 2.

You don't need to use a string for lat/lon--this is just a convenience thing (so you can use geocode attribute to populate that field in the inspector). Initialize method simply takes a Vector2d.

With regard to the duplicate tile issue, the first place I would check is your tile provider. Are you seeing duplicates immediately, or after panning, etc?

david-rhodes avatar Nov 17 '17 15:11 david-rhodes

After completely getting rid of our own implementation from earlier versions, and now using Mapbox as it probably was intended, things are working fine. 👍 - no more duplicates...

But, a quick note, in AbstractMap.cs line 67, protected MapboxAccess _fileSouce, it should be _fileSource right?

Alexphauge avatar Nov 20 '17 11:11 Alexphauge

@Alexphauge yeah--good catch with the typo 😏.

david-rhodes avatar Nov 20 '17 16:11 david-rhodes

And one more little question, in the DynamicZoomMapVisualizer map.Zoom is used a couple of times, but _map.Zoom as well, this incoherent use of _map versus map continues for quite some bit. Is there any reason for this?

If there is, I'd love to understand what the differences are between the base _map and the overridden map.

Alexphauge avatar Nov 20 '17 17:11 Alexphauge

My resharper also tries to tell me that RectD.cs constructor should have a : this() at the end.. Like this: public RectD(Vector2d min, Vector2d size) : this() - not sure why Resharper sees it as an error, but maybe you know something about it :)

Alexphauge avatar Nov 20 '17 17:11 Alexphauge

And one more little question, in the DynamicZoomMapVisualizer map.Zoom is used a couple of times, but _map.Zoom as well, this incoherent use of _map versus map continues for quite some bit. Is there any reason for this?

I think this is just an oversight/mistake on our part. Really, it should be one or the other (protected field, or passed into method as a parameter). That said, we have a new version of DynamicZoom coming soon.

david-rhodes avatar Nov 20 '17 20:11 david-rhodes