在谷歌地图上显示用户上传的照片

时间:2015-01-21 20:38:57

标签: javascript google-maps

是否可以在Google地图上显示用户上传到我网站的照片?

我发现在16月6日即将死亡的panoramio,它可以在照片商店中使用。

基本上,一旦用户将照片上传到我的网络应用,我想在谷歌地图上显示。我知道用户的位置。

是否有API,js或简单的方法来执行此操作?

1 个答案:

答案 0 :(得分:0)

你可以试试这个。您可能应该有一个后台服务,可以自动创建缩略图并将URL存储在您的数据库中。因此,您将缩略图url,fullImageUrl和该地点的坐标传递给以下函数。这里缩略图用作标记图像或图标,您可以给它任何你想要的尺寸。

    function CreateMarker(thumbnailUrl, coords, fullImageUrl)
    {   
        // marker icon creation   
        imageIcon = {
            url: thumbnailUrl,
            scaledSize: new google.maps.Size(10, 10); // adjust as needed
        };

        // marker creation
        var marker = new google.maps.Marker({
            position: coords,
            icon: imageIcon,
            map: map //your map object
        });

        // create info window
        var contentString = '<div class="fullImage">' + 
           '<img src=fullImageUrl /></div>'; // style with css

        var infowindow = new google.maps.InfoWindow({
            content: contentString
        });

        google.maps.event.addListener(marker, 'click', function() {
            infowindow.open(map,marker);
        });
    }

希望它有所帮助。