2amigos / yii2-google-maps-library

Google Maps API library for Yii2
https://2amigos.us
BSD 3-Clause "New" or "Revised" License
106 stars 78 forks source link

$coords must be an array of "dosamigos\google\maps\LatLng" objects #75

Open nitinpund opened 7 years ago

nitinpund commented 7 years ago

When i tried to implement the polylines i got error as $coords must be an array of "dosamigos\google\maps\LatLng" objects

I have already refered issue#48 and implemented accordingly.

after further debugging, I observed that ,$coord must be instance of LatLang, but its instance of yii/web/JsExpression, throwing exception

 in /vendor/2amigos/yii2-google-maps-library/LatLngBounds.php at line 329 , 

    public static function getBoundsOfCoordinates($coords, $margin = 0.0)
    {
        $minLat = 1000;
        $maxLat = -1000;
        $minLng = 1000;
        $maxLng = -1000;
        foreach ($coords as $coord) {
            if (!($coord instanceof LatLng)) {
                throw new InvalidParamException('$coords must be an array of "' . LatLng::className() . '" objects');
            }
            /* @var $coord LatLng */
            $minLat = min($minLat, $coord->getLat());
            $maxLat = max($maxLat, $coord->getLat());
            $minLng = min($minLng, $coord->getLng());
            $maxLng = max($maxLng, $coord->getLng());
        }

What's wrong, all implementation is same as mentioned in above reference link

tonydspaniard commented 7 years ago

The issue is with the code: https://github.com/2amigos/yii2-google-maps-library/blob/master/overlays/PolygonOptions.php#L107