fetching address's coordinates in c#.
I need to get the latitude and longitude for a building by it's (string) address - "{cityName} {StreetName} {StreetNum}". I already have these values in a datatable and I have methods to access them. all of the addresses are in the same country if that matters.
13 Replies
you'll need to use some 3rd party map API
Google for Developers
Geocoding API overview | Google for Developers
Geocoding converts addresses into geographic coordinates to be placed on a map. Reverse Geocoding finds an address based on geographic coordinates or Place IDs.
im using OpenStreetMap Nominatim API but getting an 403 error when trying to access data or something Im not really sure
check their docs, that suggests you're using the wrong credentials or otherwise don't have access to that endpoint
not free🫤
i just googled an example
ok, how can I know which APIs I have access to?
by reading their documentation to see if you need to create an account, pay for access, etc
damn now I have bureaucracies in coding
i'm trying openstreetmap's right now and have no problem using it
https://nominatim.openstreetmap.org/search?q=[address]&format=json
sorry but do you mind helping me implement this in c#? my knowledge is kind of limited to chatgpt
look up how to make requests to REST APIs in C#, there are a lot of resources
for example https://medium.com/bgl-tech/how-to-make-your-first-get-api-call-in-c-net-core-501134ee6e19
Medium
An Essential Guide to Making your first GET API Call in C# .NET Core
Call your first GET request in .NET C# using parameters, header values, and map-to models in your application: