“Get out from smog” – obtaining precise location

Get out from smog – part III

To measure the distance from the measuring station to current locaction of the user. Is required accurate data such as – latitude and logitude measurement station. Google provide useful api. I send a request to the address https://maps.googleapis.com/maps/api/geocode/json?address= and my adress station and api return me json with coordinates. Examples: I want to know where is Wawel Dragon. Adress to api: https://maps.googleapis.com/maps/api/geocode/json?address=krakowsmokwawelski. You can see exact coordinates in JSON.

Return to coding

Now i must parse JSON again… OK. It’s time to make universal extenstion class for parsing JSON.It will be look like:

Simple class which return me JToken which currenlty needs. Let’s see it on action.

As you can see I used it to get location node and then obtain information about latitudes and longsitudes.

Method GetLongitudeAfterAdress gets the data from the class which is responsible for parsing the results of the measurement station and adds to them the latitudes and longitudes.

Also I added LatitudesLongitudes model class to storage information about coordinates.

And it looks like eveything is ok. 😉

Get coordinate json


Application can now download the measuring station and, based on thier address, download thier latitudes and longitudes. The next step will be finding the nearest measuring station from the current location of the user.

Link to the project: HERE

2 Comments on ““Get out from smog” – obtaining precise location”

  1. Don’t you feel that restriction for max 2,500 request per day will not be sufficient?
    I used free Nominatim API in my project to omit this restriction.

    1. For now 2,500, it’s enough for me. But thank you for information about this API. I’ll try it for sure in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *