📜 ⬆️ ⬇️

Web 2.0, free Api, Google Maps, Cyrillic or one hard night


And then he says to me: “How is this our service without cards? Well this is not Web 2.0! ” . Hearing the sacramental "Web 2.0", I internally tensed. Usually this means a week of work without days off, for the realization of some beautiful garbage seen by the authorities on the vast expanses of the Internet. Having given a person a clever expression (and it happens), I set out to present the difficulties and dangers of developing an application for working with maps. But my flight of thought was barbarously interrupted.

“There are GoogleMaps . There everything is already done for us. They, I heard, good Api , also free. It is only necessary to fasten in a quick way. Work for a couple of hours. "

After the key phrases “in a hurry” and “Work for a couple of hours,” I realized that today's sex with a girl had covered herself with a copper basin. And indeed, in the coming days, Internet Explorer becomes my regular sexual partner.


The task seemed rather non-trivial, it was necessary to determine where, from what city the user came and display on the map. That is, the user, seeing a small little red flag indicating his dear Sukhodrishchensk, starts jumping from happiness and remains on the site forever. You also need to store the coordinates of his favorite places and, accordingly, highlight them on the map.
')
Surprisingly, Api turned out to be quite sweet and even perfectly documented; there were no problems with the positioning of the maps and the management of the marker. For joy, I even started humming songs from the repertoire of my favorite rock bands. Apparently these horrific sounds woke the programming demons, and they decided to take revenge on me.

The fact is that while the user enters his location data, he has to be positioned by geoip. He returns the coordinates, and for them you need to determine the nearest city and present it. But to find out the coordinates of a city, I need to know its name.

"Pancake. What to do? ” I said (in literary translation).

Like what? Find out in advance all the coordinates of cities and save them in the database. Seeing the goal in front of me, I was delighted and even wanted to sing, but I stopped in time (there is nothing to alarm the demons in vain). Needless to say, Google does not understand the native Cyrillic city names - only in English. “So you just need to translate!” - the demons in my head howled happily (about half past one in the night they took pity on the unenviable programmer’s share and set out to help). A couple of hours later, it turned out that everything is not so bright. Either my knowledge of grammar, I remember, was 3 in Russian, or the phase of the moon, but automatically generate the English name did not work.

“And how can I solve this problem?” I said (no, really, I said so: “And how can I solve this problem?”). For some reason, the idea of ​​using some kind of translator did not come right away ... After half an hour, the script was ready. Another couple of minutes - and all the cities are transferred.

The last step is to get these damned all gods coordinates.
Another script was written and launched, I already anticipate the joy of victory and;%;% *? MM (% Y%; *?) (Untranslatable play on words). Google banned me!
“Probably, a virus has gotten on your computer”. What kind of garbage ?! 20,000 queries at a time are normal user behavior. I live faster surf (I just have a F5 sink, so many resources think I’ve reached them).

Raising my arms to the sky, I proclaimed: “Why should all good things be done in dirty ways ?!”

Well, of course, the good old list of free proxies rescued me this time too.

And here (music of the hulk) list of cities in my database. Congratulating myself loudly (at 4 am there is still no one in the office), with a sense of accomplishment, I went in search of food. But that's another story…

Oh yes, I completely forgot. In any story there should be a meaning, well, except for stories about Friday booze. And the point is that if you want to use free Api, then get ready for what you always have to bring to mind. After all, developers write Api, guided by their own, and not your functionality. However, enjoy the benefits of others. Just count how much time you need to write your own map service! Here the selection criterion is probably the same as when selecting third-party libraries. If the functionality is key for your start up, then definitely write it yourself. That is, a photo gallery based on Flickr is unlikely to be a ride, and if this is a necessary, but a feature, well, then you can play around with someone else’s Api.

And yet, for any (even the most useful and good deed) a list of free proxy is still needed.

Source: https://habr.com/ru/post/9121/


All Articles