Coordinates with React Native Maps
Coordinates are fun. Been working out what exactly delta lat/lng are which is a part of React Native Maps.
It’s for the viewport! I’ve been testing this out by calculating the top left and bottom right and then testing those coords with this neat tool.
const bottomLeft = `${latitude - latitudeDelta / 2}, ${longitude - longitudeDelta / 2}`
const topRight = `${latitude + latitudeDelta / 2}, ${longitude + longitudeDelta / 2}`
console.log(bottomLeft, topRight);
I was kind of already doing that on the API I’d built, but I’d hardcoded the values, which of course doesn’t accomodate for pretty much anything, viewport size, rotating, zooming and all the kinds of stuff that users do with maps. I’ll probably set a restriction on the delta so that I don’t send down all db records - there’s no reason to.
React Native Maps is pretty good to be honest. I tried setting up iOS to use Google Maps but that seems to be a massive pain in the ass, so I’ve stuck with Apple Maps for now for MVP. It’s a case of out of date docs. It’s a shame when that happens, when great software built but outdated docs result in devs having a bad time using it, or not even using it at all.