【问题标题】:Showing user uploaded photos on google map在谷歌地图上显示用户上传的照片
【发布时间】:2015-01-21 20:38:56
【问题描述】:

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

我在 6 月 15 日发现了 panoramio,它可以在照片商店中使用。

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

是否有 API、js 或简单的方法可以做到这一点?

【问题讨论】:

标签: javascript google-maps


【解决方案1】:

你可以试试这个。您可能应该有一个后台服务,它会自动创建缩略图并将 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);
        });
    }

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-26
    • 1970-01-01
    • 1970-01-01
    • 2019-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多