Skip to content

Commit 3d6131a

Browse files
committed
feat: project method to go from latlng to screen coords
1 parent 659dace commit 3d6131a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/mapbox.android.ts

+5
Original file line numberDiff line numberDiff line change
@@ -3267,6 +3267,11 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
32673267
}
32683268
return Promise.all(iterations).then((output) => result);
32693269
}
3270+
project(data: LatLng) {
3271+
const mapboxPoint = new com.mapbox.mapboxsdk.geometry.LatLng(data.lat, data.lng);
3272+
const screenLocation = this._mapboxMapInstance.getProjection().toScreenLocation(mapboxPoint);
3273+
return { x: screenLocation.x, y: screenLocation.y };
3274+
}
32703275
}
32713276

32723277
export class Layer implements LayerCommon {

src/mapbox.ios.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2573,6 +2573,12 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
25732573
}
25742574
});
25752575
}
2576+
2577+
project(data: LatLng) {
2578+
const theMap: MGLMapView = this._mapboxViewInstance;
2579+
const { x, y } = theMap.convertCoordinateToPointToView({ latitude: data.lat, longitude: data.lng }, theMap);
2580+
return { x, y };
2581+
}
25762582
}
25772583

25782584
const _addObserver = (eventName, callback) => NSNotificationCenter.defaultCenter.addObserverForNameObjectQueueUsingBlock(eventName, null, NSOperationQueue.mainQueue, callback);

0 commit comments

Comments
 (0)