Search for closeness

Asked

Viewed 374 times

4

I am in search of tutorials that help me implement a search for proximity (as in this link:https://www.palfinger.com/pt-BR/bra/representantes-de-vendas/localizador-de-representante). Note that besides its location it uses other filters (select and checkbox). Well, my fort is front-end, but I’ve started learning PHP and mysql.

How do I get this result? What kind of tutorials should I look for? What languages are used? Anything you can enlighten me on that would be great.

Thank you in advance.

  • Look at http://www.banco24horas.com.br/para-voce/busca-banco24-horas

  • here is the API: https://developers.google.com/maps/documentation/javascript/examples/places-searchbox

1 answer

1

In PHP that’s basically it:

   public function getGeocodeAddress($lat, $long)
        {
            $url = "https://maps-api-ssl.google.com/maps/api/geocode/json?latlng=" . $lat . "," . $long . "&sensor=true";

            $data = @file_get_contents($url);
            $jsondata = json_decode($data, true);
            if (is_array($jsondata) && $jsondata['status'] == "OK") {
                $addressComponents = $jsondata['results'];
                for ($i = 0; $i < count($addressComponents); $i++) {
                    for ($j = 0; $j < count($addressComponents[$i]['address_components']); $j++) {
                        $typeName = $addressComponents[$i]['address_components'][$j]['types'][0];
                        if ('locality' == $typeName) {
                            return strtolower($addressComponents[$i]['address_components'][$j]['long_name']);
                        }
                    }
                }
            }
            return null;
        }

Look at the way out: http://ideone.com/rePEIv

Browser other questions tagged

You are not signed in. Login or sign up in order to post.