objectivehtml/Google-Maps-for-Craft

GoogleMaps_TemplatesService.php data function looks to be broken

Opened this issue · 0 comments

When calling the data function on line 96 of GoogleMaps_TemplatesService.php the inputted $data is decoded and then not used. On the next line (102) $data is being reset to a new GoogleMaps_MapDataModel that is empty because the decoded $data variable is not getting passed in, $value is getting passed in an is type hinted as a array, so I suspect it's being set to an empty array by default so it's not throwing an error.

GoogleMaps_TemplatesService.php -> data()

public function data($id, $data = '', $options = array())
    {
        if(is_string($data))
        {
            $data = json_decode($data);

            $data = new GoogleMaps_MapDataModel((array) $value);
        }

        craft()->templates->includeJs('new GoogleMaps.MapData('.$id.','.$data->toJson().','.$this->jsonEncode($options).');');
    }

Should be :

public function data($id, $data = '', $options = array())
    {
        if(is_string($data))
        {
            $data = json_decode($data);

            $data = new GoogleMaps_MapDataModel((array) $data);
        }

        craft()->templates->includeJs('new GoogleMaps.MapData('.$id.','.$data->toJson().','.$this->jsonEncode($options).');');
    }