【问题标题】:Custom map use Google maps or touch with an image?自定义地图使用谷歌地图还是触摸图像?
【发布时间】:2015-09-19 17:54:14
【问题描述】:

我很困惑显示地图的最佳路线是什么如果这足够好,我应该使用带有瓷砖覆盖的谷歌地图来让图像覆盖地图吗?然后我会让每个带有项目的图块都可以点击,或者有一个带有触摸坐标的图像?最好的路线是什么?

【问题讨论】:

    标签: android google-maps dictionary google-maps-api-2


    【解决方案1】:

    假设您使用的是 javascript 地图 API。最好和最通用的方法是在单击标记本身时创建一个信息框。 做起来比下面说的容易

    function setMarker(p) {
    
        var title = '<div><img src="icon_header_i_focus.png" onClick = "getDetails('
                + n
                + ')" /><div id ="place" style = "height:100%;width:100%" onClick = "getDetails('
    
                + ')"><label for="Name">'
                + PlaceName
                + '</label><br><label for="Address">'
                + PlaceAddress
                + '</label> </div><div id= "direction" ><a  href="javascript:getDirections('
    
                + ')">directions</a>'
                + '</div></div>';
    
    
        var marker = new google.maps.Marker({
            icon : markerImage,
            map : map,
            position : pos,
            animation : google.maps.Animation.DROP
        });
    
        google.maps.event.addListener(marker, 'click', function() {
            if (infowindow) {
                infowindow.close();
            }
            ;
            infowindow = new google.maps.InfoWindow({
                content : title,
                maxWidth : 300
            });
            infowindow.open(map, marker);
        });
    

    【讨论】:

    • 我正在使用我提到的android api,但无论如何我有标记不确定它是否会看起来很乱,而不是放置图像
    【解决方案2】:

    如果您不喜欢默认标记,您可以随时使用MarkerOptions.icon() 创建自己的标记图像。

    如果您想在地图上绘制图像,您可能需要ground overlays 而不是tile overlay(前者您为地图提供单个叠加图像和位置,而地图负责细节,后者您需要处理将图像切割成具有不同缩放级别的图块)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-21
      • 2020-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多