簡體   English   中英

HTML 谷歌地圖看不到標記

[英]HTML Google Maps can't see markers

我正在嘗試使用標記創建地圖。 但是在下面的代碼中我看不到標記。

<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps - pygmaps </title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=visualization&sensor=true_or_false"></script>
<script type="text/javascript">
    function initialize() {
        var centerlatlng = new google.maps.LatLng(37.427000, -122.145000);
        var myOptions = {
            zoom: 16,
            center: centerlatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        var latlng = new google.maps.LatLng(37.427000, -122.145000);
        var img = new google.maps.MarkerImage('C:\Python27\lib\site-packages\gmplot\markers\D8BFD8.png');
        var marker = new google.maps.Marker({
        title: "no implementation",
        icon: img,
        position: latlng
        });
        marker.setMap(map);

        var latlng = new google.maps.LatLng(37.428000, -122.146000);
        var img = new google.maps.MarkerImage('C:\Python27\lib\site-packages\gmplot\markers\6495ED.png');
        var marker = new google.maps.Marker({
        title: "no implementation",
        icon: img,
        position: latlng
        });
        marker.setMap(map);

        var latlng = new google.maps.LatLng(37.429000, -122.144000);
        var img = new google.maps.MarkerImage('C:\Python27\lib\site-packages\gmplot\markers\000000.png');
        var marker = new google.maps.Marker({
        title: "no implementation",
        icon: img,
        position: latlng
        });
        marker.setMap(map);

    }
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
    <div id="map_canvas" style="width: 100%; height: 100%;"></div>
</body>
</html>

例如: C:\\Python27\\lib\\site-packages\\gmplot\\markers\\6495ED.png存在。 我可以看到有圖像但圖像沒有出現在地圖上。 誰能說我該如何解決這種情況?

你的路徑不正確。 例如使用此 URL 更改它。 https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png你會看到標記。

您可以在此處找到有關標記圖標的更多信息https://developers.google.com/maps/documentation/javascript/examples/icon-complex?hl=ru

我最近遇到了類似的問題,只是使用正斜杠而不是反斜杠修復了它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM