dongpo9071 2018-04-17 04:51
浏览 41

Google maps API - 具有多个PlaceID的多个地图

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;?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥15 基于52单片机的酒精浓度检测系统加继电器和sim800
    • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答