You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not able to properly visualize IconLayers on my Globe-projected DeckGL instance.
In my React-Maplibre-MapboxOverlay implementation mercator projection shows up great, but globe projection glitches out. (tested both interleaved/overlaid)
Screen.Recording.2025-03-29.at.4.14.08.PM.mov
In my (codepen using script tag) reproduction, I am actually able to see the point when the globe is oriented such that the Icon extrudes in the right direction, however, in my implementation, the point disappears after any user interaction.
Additionally, in the reproduction, the IconLayer instances do not show up in the right location. Notice how the coordinates of the sample points are all within Florida, however, the IconLayer shows up at the origin
I managed to work around this by turning off depthTest and filter my dataset with this method based on the camera position:
// Helper function to determine if a feature is visible from a camera's pov on globe projectionfunctionisFeatureVisibleOnGlobe(cameraLat: number,cameraLon: number,featureLat: number,featureLon: number,zoom: number,): boolean{consttoRad=(deg: number)=>(deg*Math.PI)/180;// Convert lat/lon to radiansconstcamLatRad=toRad(cameraLat);constcamLonRad=toRad(cameraLon);constfeatLatRad=toRad(featureLat);constfeatLonRad=toRad(featureLon);// Convert to unit vectorsconsttoVec3=(lat: number,lon: number): [number,number,number]=>{return[Math.cos(lat)*Math.cos(lon),Math.sin(lat),Math.cos(lat)*Math.sin(lon),];};constcamVec=toVec3(camLatRad,camLonRad);constfeatVec=toVec3(featLatRad,featLonRad);// Compute dot productconstdot=camVec[0]*featVec[0]+camVec[1]*featVec[1]+camVec[2]*featVec[2];// Convert zoom level to a tighter FOV thresholdconstfovDegrees=zoomToFOV(zoom);// field of view in degreesconsthalfFovCos=Math.cos(toRad(fovDegrees/2));// If the angle between the vectors is within the cone, dot ≥ cos(halfFOV)returndot>=halfFovCos;}// Tune this mapping to match your renderer behaviorfunctionzoomToFOV(zoom: number): number{constclamped=Math.max(Math.min(zoom,20),1);// At zoom 1 → full hemisphere (≈130° FOV), at zoom 20 → tight 0° FOVreturn130*(1-(clamped-1)/19);// Range: 130 → 0 degrees}
//assumes data is a geojson feature collection with Point geometriesnewIconClusterLayer<GeoJSON.Feature<GeoJSON.MultiPoint,GeoJSON.GeoJsonProperties>>({data: data.features.flatMap((feature)=>feature.geometry.coordinates.map((coordinate)=>({type: "Feature",geometry: {type: "Point",coordinates: coordinate,},properties: feature.properties,})),).filter((feature)=>{const[lng,lat]=feature.geometry.coordinates;returnisFeatureVisibleOnGlobe(vs.longitude,vs.latitude,lng,lat,vs.zoom,);}),
...
parameters: {depthTest: false,},}),
Description
I am not able to properly visualize IconLayers on my Globe-projected DeckGL instance.
In my
React-Maplibre-MapboxOverlay
implementation mercator projection shows up great, but globe projection glitches out. (tested both interleaved/overlaid)Screen.Recording.2025-03-29.at.4.14.08.PM.mov
In my (codepen using script tag) reproduction, I am actually able to see the point when the globe is oriented such that the Icon extrudes in the right direction, however, in my implementation, the point disappears after any user interaction.
Additionally, in the reproduction, the IconLayer instances do not show up in the right location. Notice how the coordinates of the sample points are all within Florida, however, the IconLayer shows up at the origin
Original Comment: #9199 (comment)
Flavors
Expected Behavior
I would expect the IconLayer to behave as it normally does in the
"mercator"
projection.Steps to Reproduce
https://gist.github.com/charlieforward9/7637c8598caa1537ac965ed1603dcdbe
Environment
Logs
No response
The text was updated successfully, but these errors were encountered: