Pigeon Maps – Maps in React with no external dependencies
mariusandra.github.io
mariusandra.github.io
This is loading all data from maps.wikimedia.org.
Tracing route to maps.wikimedia.org [103.102.166.240] over a maximum of 30 hops:
1 <1 ms 3 ms 2 ms 192.168.1.1
2 7 ms 6 ms 6 ms abts-north-static-076.220.160.122.airtelbroadband.in [122.160.220.76]
3 8 ms 5 ms 9 ms 125.17.2.173
4 7 ms 10 ms 6 ms 182.79.181.72
5 51 ms 51 ms 65 ms 182.79.149.237
6 47 ms 50 ms 47 ms 182.79.198.2
7 73 ms 73 ms 72 ms 182.79.224.181
8 73 ms 73 ms 72 ms 14907.sgw.equinix.com [27.111.228.186]
9 79 ms 79 ms 93 ms upload-lb.eqsin.wikimedia.org [103.102.166.240]
Now Google Maps seems to be serving all data from root domain www.google.co.in. So here we go.Tracing route to www.google.co.in [172.217.167.35] over a maximum of 30 hops:
1 <1 ms 1 ms 1 ms 192.168.1.1
2 8 ms 5 ms 6 ms abts-north-static-076.220.160.122.airtelbroadband.in [122.160.220.76]
3 6 ms 6 ms 5 ms 125.18.20.57
4 10 ms 7 ms 6 ms 72.14.205.93
5 42 ms 44 ms 42 ms 108.170.251.113
6 8 ms 7 ms 14 ms 72.14.234.117
7 8 ms 7 ms 7 ms del03s16-in-f3.1e100.net [172.217.167.35]
So even after getting additional latency penalty of ~60ms, it still feels snappier! Imaging it could be even more faster with local CDN nodes. 60ms = ~3 Frames on 60Hz Monitor refresh rate.It is to be expected that this is quicker on any halfway decent internet connection.
Google Maps seems to be the worst, even on my recent Macbook Pro and 60mbps Internet, scrolling feels like I'm pushing heavy furniture across an unfinished concrete floor. I can almost feel it scratching and scraping and resisting every attempt to pan left or right.
In the era of "mobile first" and PWAs and all that, how is it that we require a rock solid Internet connection and a super fast processor with gobs of RAM just to get a shitty experience on the web? And if either one of those drops in the slightest, you're locked out solid.
Completely unrelated and irrelevant observation though... I found the use of buttons to mimic checkboxes feels a bit odd to me.
Also, Github repo link for those who want to see the source or star it, since there is no link on the demo right now: https://github.com/mariusandra/pigeon-maps
And for the checkbox buttons... oh well :D
I recently whipped up a quick hobby project where I'm displaying a map on an old kindle by running wkhtmltoimage on a server and displaying the png. It's got a giant delay in responding with a lot of it due to Mapbox initialization time.
Otherwise no, there is no write up of the process. I might do one some day, thanks for the idea.
speaking of which, why do people debate about whether forks on github are persistent even when the author removes their copy, when you can always clone either way, since that keeps a copy on your system and you still have the code
Alternatively, you can try preact [1] or inferno [2] and for a few KB more you have something that is still smaller than Google Maps or Leaflet.
Of course if you need more advanced features and geometric calculations the size can go up considerably. Leaflet and Google Maps provide that out of the box. Pigeon-maps doesn't.
You can also strip Leaflet down to just the raster tile layer stuff and as it doesn't need react or preact or inferno it will be lighter weight than your solution, and still uses the fundamental underlying display mechanism of image tags.
I have never claimed it to match the features of Leaflet while being lighter. It's lighter exactly because it doesn't. Offloading a lot of DOM work to React makes it even lighter.
Edit: to correct one point, pigeon-maps does support mobile.
What exactly does this mean? The only thing that ever changes, as I mentioned, is the src of the image tags in these kinds of tiled maps. How do you get better performance for updating the src attributes in a grid of images of constant size (256x256 tiles or whatever) other than img.src = ''? That's literally the only DOM manipulation being done, there is no "magic".
Also you can reduce a lot of your mouse event handling stuff down to a single "reactive" (haha) callback by doing something like this: https://github.com/mikolalysenko/mouse-event. Instead of binding a bunch of different handlers, the browser's mouse events API is still bizarre after all these years. Should just be a single event that gets sent the state of control input.
What about markers?
And that's not to mention the things being displayed on the map, like popups, markers, or polygons. Which React's model helps a lot with.