1

I've searched an answer for a while but all i can find consists of LatLong. I want to use PlaceID. The following code works on a single map with multiple markers but not with two different maps. The first instance of map with markers works. Second shows only map. Data is the same for both except for the parameter map_(group).

            <?php $markers = $data->getMarkers($group);
        if ($markers):
            $counter = 0;

            // Markers
            foreach ($markers as $marker):
                $counter++;
                // Marker icon
                if ($marker['icon']):
                    $marker_image = $data->getMedia() . 'googlemap/' . $marker['icon']; ?>
                    var image<?php echo $counter ?> = {
                        url: "<?php echo $marker_image; ?>"
                    };
                <?php endif;?>


                var service = new google.maps.places.PlacesService(map_<?php echo $group; ?>);
                service.getDetails({placeId: '<?php echo $marker['coordinates']; ?>'}, function(result, status) {
                    if (status != google.maps.places.PlacesServiceStatus.OK) {
                        alert(status);
                        return;
                    }

                    // Marker init
                    var marker = new google.maps.Marker({
                        map: map_<?php echo $group; ?>,
                        position: result.geometry.location<?php if (strlen($marker['icon']) > 0) { ?>,
                        icon: image<?php echo $counter ?><?php }; ?>
                    });
                    // Infowindow
                    var infowindow = new google.maps.InfoWindow();
                    var content = "<?php echo $data->getContentInfowindow($marker['infowindow']); ?>";
                    infowindow.setContent(content);
                    infowindow.open(map_<?php echo $group; ?>, marker);
                });
            <?php endforeach;?>
4

0 回答 0