Comments (7)
This due to how path are drawn. MapCompose uses Canvas.drawLines
which is hardware accelerated, but rendering isn't as pretty as Canvas.drawPath
as your image shows.
Historically, I chose to ditch drawPath
because the performance difference can clearly be felt when rendering long paths. I was ok with it since in this case I value performance more than aesthetics.
Now a few years later I gave drawPath
another try. It's in the very experimental drawpath
branch.
While the demo performs well, my testing on a real app shows a noticeable performance difference. Also, I've seen paths blinks under some circumstances (but this is probably unrelated to drawPath
).
It would be nice to investigate this performance issue and see if there's a way to use drawPath
while not hindering performance. In the end, I agree paths could look nicer. However I will be careful about performance.
from mapcompose.
The only idea I have for now is to implement path simplification. When zooming out, a path with 10k points can be simplified to a few dozen lines. This should have impact on performance. However this isn't easy to implement.
EDIT: I've implemented the Ramer–Douglas–Peucker algorithm. The result is amazing. Looks like this fixes the performance issue.
from mapcompose.
@Nohus Could you test the branch drawpath
and give me your feedback? It should render path like Google Maps Compose library, plus with a path decimation algorithm to fix performance on zoom out.
from mapcompose.
Impressive work! I can confirm it works well.
I noticed a small issue: the paths seem to be drawn without anti-aliasing and have jagged edges, especially visible at particular angles. I tried setting isAntiAlias = true
on the Paint
object but it didn't seem to help.
The path simplification is really good, but I think it's a little bit too aggressive, I can see my paths jumping around as I zoom in and out. I think it may work better for you (and be more required) because you are using paths made of a lot of points. My points are not very dense already.
Updating the epsilon argument from 2.dp
to 1.dp
made it more sensible, at least on my path data.
val epsilon = with(LocalDensity.current) {
(1.dp / zoomPRState.scale).toPx().toDouble()
}
from mapcompose.
Ok for reducing the epsilon.
I'm surprised you have an anti-aliasing issue. On my device it renders perfectly. Did you have the issue with previous paths?
I'll double check.
from mapcompose.
I rechecked on a physical device and the paths render correctly, it seems the anti-aliasing issue was emulator-specific, maybe the emulator I used lacks hardware acceleration. False alarm!
from mapcompose.
I'm relieved!
from mapcompose.
Related Issues (20)
- Unable to add polygon lines in Mapstate HOT 1
- Add lat/long versus relative support HOT 7
- [Feature request]Allow each layer has different tileSize
- Html support
- Marker composable content update HOT 3
- Question: How to handle marker/cluster removal efficiently HOT 13
- Tiles of size smaller than specified to `MapState` are not garbage-collected HOT 7
- Performance degradation when using null tiles HOT 13
- Zoom not work HOT 5
- Path: Ability to use pattern HOT 4
- Bug: Marker size (width) is limited to screen width HOT 2
- Problem: Click callback uses outdated data HOT 5
- Custom figures and objects HOT 1
- How to set min/max zoom levels? HOT 5
- GPS coordinates to normalized coordinates HOT 8
- [Feature Request] Support for vector tiles HOT 2
- Solved: Very large Marker size is causing crash HOT 5
- MapTiler Raster Tile Amount HOT 1
- Support for tap regions HOT 2
- Add carousel effect HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapcompose.