alexpechkarev / google-maps

Collection of Google Maps API Web Services for Laravel
https://alexpechkarev.github.io/google-maps/
MIT License
520 stars 115 forks source link

containsLocation() is not working #94

Closed wailashraf71 closed 3 years ago

wailashraf71 commented 3 years ago

I'm trying this example:

        $response = (new \GoogleMaps\GoogleMaps)->load('directions')
            ->setParam([
                'origin' => 'place_id:ChIJ685WIFYViEgRHlHvBbiD5nE',
                'destination' => 'place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y',
            ])->containsLocation(55.86483, -4.25161);

        return dd($response);  //

But getting this error on laravel

### ErrorException
count(): Parameter must be an array or an object that implements Countable

vendor\alexpechkarev\geometry-library\PolyUtil.php:99
            tan($lat3) >= self::tanLatGC($lat1, $lat2, $lng2, $lng3) :
            MathUtil::mercator($lat3) >= self::mercatorLatRhumb($lat1, $lat2, $lng2, $lng3);
    }

    public static function containsLocation($point, $polygon, $geodesic = false) {
        **$size = count( $polygon );**
        if ($size == 0) {
            return false;
        }
toro-terminator commented 1 year ago

How are you calculating a polygon with only an origin and a destination?