bradcornford / Googlmapper

An easy way to integrate Google Maps with Laravel
MIT License
464 stars 142 forks source link

Map not render, if your markers more than 100 #305

Closed malvinys closed 4 years ago

malvinys commented 6 years ago

hi, i want to render a map with many markers. If the marker is less than 100, map will be rendered, otherwise map is not rendered.

this is my code :

                           $i = 0;
                foreach ($data as $key_data) {
                    if ($i == 0) {
                        Mapper::map($key_data->lat, $key_data->lng, 
                            [
                                'zoom'     => 15, 
                                'marker'   => false, 
                                'cluster'  => true, 
                                'clusters' => ['center' => true, 'zoom' => 20, 'size'=> 10], 
                                'language' => 'en'
                            ]); 
                        Mapper::informationWindow(
                            $key_data->lat, $key_data->lng, 
                            "Name : ".$key_data->created_by.
                            "<br>Dept : ".$key_data->dept.
                            "<br>Last Time Check : ".$key_data->created_at.
                            "<br>Activity : ".$key_data->category,
                            [
                                'center'    => true,
                                'autoClose' =>true,
                                'animation' => 'DROP', 
                                'icon'      => $key_data->img_url
                            ]
                        );
                    } else {
                        Mapper::informationWindow(
                            $key_data->lat, $key_data->lng, 
                            "Name : ".$key_data->created_by.
                            "<br>Dept : ".$key_data->dept.
                            "<br>Last Time Check : ".$key_data->created_at.
                            "<br>Activity : ".$key_data->category,
                            [
                                'center'    => true,
                                'autoClose' =>true,
                                'animation' => 'DROP', 
                                'icon'      => $key_data->img_url
                            ]
                        );
                    }
                    $i++;
                }
mikE83 commented 5 years ago

I’ve the same issue how you resolv that???

bradcornford commented 5 years ago

Hi,

You're running into a common issue, where the map struggles to process large number of markers. A good solution to this is to utilise marker clustering.

Here's an example of how its used from the README:

Mapper::map(53.381128999999990000, -1.470085000000040000, ['zoom' => 10, 'markers' => ['title' => 'My Location', 'animation' => 'DROP'], 'clusters' => ['size' => 10, 'center' => true, 'zoom' => 20]]);