nativescript-community / nativescript-community/ui-mapbox

circle-radius interpolation on iOS not working anymore

Open
#51 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
38
Forks
26
PR merge metrics
No merged PRs in 30d

Description

I updated the mapbox plugin from 5.0.0 to 6.2.9 and noticed that the circle-radius interpolation is not working anymore on iOS. Which means that a circle won't be adjusted in size according to the zoom level. The functionality was removed in PR #8

so basically this was removed

const nsDict = new (NSDictionary as any)(stopValues, stopKeys);

const nsArray = NSArray.arrayWithArray([nsDict]);

layer.circleRadius = NSExpression.expressionWithFormatArgumentArray("mgl_interpolate:withCurveType:parameters:stops:( $zoomLevel, 'exponential', 2, %@)", nsArray);

and replaced with a TODO

if (propertiesObject['circle-radius']) {
     if (typeof propertiesObject['circle-radius'] !== 'number') {
         throw new Error('Unsupported circle-radius type'); // TODO: Implement circle radius with stops
     }
     circleProperties['circleRadius'] = NSExpression.expressionForConstantValue(propertiesObject['circle-radius']);
 }

I tried to reintroduce the functionality and created a dictionary with some test values for the NSExpression

const nsDict = new (NSDictionary as any)([0, 5147], [0, 20]);
const nsArray = NSArray.arrayWithArray([nsDict]);
const expression = NSExpression.expressionWithFormatArgumentArray("mgl_interpolate:withCurveType:parameters:stops:( $zoomLevel, 'exponential', 2, %@)", nsArray);

but I get the following error at runtime

MapComponent:addCircle(): addCircle threw an error:Error: Unable to convert JSON object mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, "linear", nil, {0 = 0, 20 = 5147}) to an NSExpression.

Which is weird since the same code was running in the old plugin version. Could it have something to do with the iOS-runtime? My project with the old plugin is running the iOS runtime 6.5.4 where as the new is project is running 8.0.0.

@cvietor did you run into the same issue while refactoring for the above mentioned PR? Might that be the reason you left it as a TODO?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the circle-radius handling in addCircle() and compare the current TODO with the removed implementation from PR #8. Reproduce the stop-based expression on the affected iOS runtime versions; done means circle-radius interpolation works by zoom level without the NSExpression conversion error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.