HTML 谷歌地图看不到标记



我正在尝试创建带有标记的地图。但是在以下代码中,我看不到标记。

<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:Python27libsite-packagesgmplotmarkersD8BFD8.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:Python27libsite-packagesgmplotmarkers6495ED.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:Python27libsite-packagesgmplotmarkers00000.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:Python27libsite-packagesgmplotmarkers6495ED.png顺便说一句。我可以看到有图像,但是图像不会出现在地图上。谁能说我该如何解决这种情况?

您的路径不正确。用例如此URL更改它。https://developers.google.com/maps/documentation/javascript/examplect/full/images/beachflag.png您会看到标记。

您可以在此处找到有关标记图标的更多信息https://developers.google.com/maps/documentation/javascript/examples/icon-complex?hl=ru

我最近有一个类似的问题,只使用前向斜线而不是固定后斜线

最新更新