2 ms·
You don't need any API keys or any payments or anything. Just get a "shapefile" or geojson of world countries, like this one: https://datahub.io/core/geo-countr
by solardev 4y ago
You don't need any API keys or any payments or anything. Just get a "shapefile" or geojson of world countries, like this one: https://datahub.io/core/geo-countries https://datahub.io/core/geo-countries
These are vector formats very similar to SVG except with an understanding of geo coordinate systems and projections.
Then use openlayers or leaflet to render it in whatever projection you want, using wgs84 as your coordinate reference system.
The earth isn't a perfect sphere so you can't just draw a floating grid around a ball and call it a day. The transformation math is complicated. You can look at the mapping engines source code if you want, or just use them.
To add blue dot GPS positioning, you'll have to use Javascript to request the browser location or ip geolocation to guess it. Once you get that you can tell the openlayers to zoom to it and draw a dot and tell you which country it's in using by looking at how it intersects the country polygons.
All of that is totally free with no API keys or payments. You can self host all of it with no third party connections.