An Update on AI Coding
In my last post, I shared how AI has become an unexpected ally in my journey as a developer, helping me navigate tasks that once felt daunting.
Today, I'm excited to dig into a real example that shows just how powerful (and a little mind-blowing) this technology can be, especially for those of us who aren’t exactly maths experts.
Here’s a look at how I tackled an upgrade in one of my older apps with a new mapping API, thanks to some AI assistance.
The Problem: Getting Map Zoom Right
I’m adding a new Map
API to an existing app, including a feature where users can search within a set distance to public transport.
I wanted to zoom the map to fit only the specified search area. Simple enough, right? Well, here’s the challenge: I needed a formula to calculate the camera’s distance from the ground based on the user’s selected search radius.
How AI Solved the Maths (and Taught Me Something New)
Instead of just giving me the answer, the AI provided a clear breakdown of how mapping distances work. Here's what happened step-by-step:
- Setting Up the Basics
I asked for a formula to calculate the height the camera should be to fit the search area. The AI quickly provided me with a code snippet that included a cameraHeightMultiplier
, which was set to 4. However, I couldn’t understand why this multiplier was set to 4, so I asked the AI where that number came from.
- The AI’s Explanation
Rather than leaving me in the dark, the AI explained that the multiplier of 4 is something of a "magic number" in mapping APIs — derived more from experience and empirical testing than pure maths. But it still had reasons to back it up:
- Basic Trigonometry: With a 45° field of view, you'd theoretically need a height of approximately
D
to view a ground distanceD
. To fit a circle with diameter2R
, you’d need to be at a height of2R
.
- Practical Adjustments: The Earth’s curvature, screen aspect ratios, and mobile device variability all make it trickier to get consistent, user-friendly results. A bit of padding is added for a better user experience, and a multiplier of 4 is often a reliable fit across devices and scenarios.
- Beyond Words — an SVG Diagram
After the explanation, things got even more interesting. The AI started generating SVG code for me. It didn’t just talk me through the theory but actually drew a diagram to show the camera height, the field of view, and the effect of padding around the edges. This visual aid was incredibly helpful, allowing me to see exactly what it was describing in real time.
Why This Matters: AI as a Learning Partner, Not Just a Problem Solver
What struck me most in this whole process wasn’t just the formula or the code snippet, but the way the AI broke down the problem into manageable pieces.
Instead of just giving me an answer, it explained the reasoning behind it, deepening my understanding of something that once seemed out of reach.
The addition of an SVG diagram was like the AI saying, "Here, let me show you."
How This Changes Development for Me
With AI, I’m no longer left scratching my head over formulas or complex calculations. I can dig into new areas of development without getting bogged down by my knowledge gaps.
More importantly, I can take on new features with a much stronger understanding of how things work, which ultimately makes me a better developer.
If there’s one takeaway from this experience, it’s this: AI is not just a tool for writing code; it’s a teacher, an explainer, and a visual assistant all wrapped into one. And I, for one, am looking forward to discovering where it takes me next.
This was using Claude.ai
for the above generation.
If you found this article helpful, you can keep the ideas flowing by supporting me. Buy me a coffee or check out my apps to help me create more content like this!
Coffee Check out my apps