Monday, October 23, 2023
HomeiOS Developmentios - Changing GPS coordinates to Steel Layer coordinates for Mapbox Maps

ios – Changing GPS coordinates to Steel Layer coordinates for Mapbox Maps


I’m making an attempt to attract a triangle connecting Berlin, Kyiv & Helsinki(or any such location) on a CustomLayer with Mapbox iOS SDK utilizing Steel. The triangle ought to transfer with the map and these cities when the map is zoomed or dragged.

Coordinates for these places are Longitude and Latitude. Whereas the drawing something in Steel requires coordinates the place heart is center of the display, from BottomLeft(-1, -1) to TopRight(1, 1). My drawing requires the conversion of Lengthy & Lat to Steel GL drawing coordinates system. One thing like –

let berlin: simd_float2 = MapboxUtil.MercatorCoordinate(fromLongitude: 13.403,
                                                             latitude: 52.562)

I believe I can do some maths and convert the 360 deg Lengthy & Lat to a 2.0 unit scale that the Steel’s canvas can perceive. However this must keep in mind the zoom stage, a part of the map seen on the display and so on. One thing like what @nauti has carried out in this reply. And this calculation can be carried out everytime the map is rendered(60 instances a second) and the identical calculation will occur when the map is moved or the zoom stage is modified. Looks as if lots of calculations. Ideally there ought to be a manner within the SDK try this or atleast some utility technique.

Lengthy story brief, am I approaching the issue in a unsuitable manner? Has anybody carried out one thing comparable? How do I convert the coordinates from one system to a different? What half goes contained in the shader.

In fact, I’ll draw somewhat extra advanced object in my last software. The triangle connecting Cities is only for my understanding.

I’m making an attempt to make use of Mapbox iOS SDK on iOS with Swift.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments