0

我正在开发的网站上有两个谷歌地图设置,我想将自定义标记应用于它们。这是我写的——

    var coordinates_1 = new google.maps.LatLng(x, x);
    var coordinates_2 = new google.maps.LatLng(x, x);
    var map_1_options = {
        zoom: 14,
        center: coordinates_1,
        mapTypeControl: false,
        streetViewControl: false,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map_2_options = {
        zoom: 14,
        center: coordinates_2,
        mapTypeControl: false,
        streetViewControl: false,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var marker_1 = new google.maps.Marker({
        position: coordinates_1, 
        map: map_1,
        icon: '/images/marker.png'
    });
    var marker_2 = new google.maps.Marker({
        position: coordinates_2, 
        map: map_2,
        icon: '/images/marker.png'
    });
    var map_1 = new google.maps.Map(document.getElementById('location_1'), map_1_options);
    var map_2 = new google.maps.Map(document.getElementById('location_2'), map_2_options);

我猜脚本可以优化,但这不是这里的重要问题。发生的情况是我没有收到任何错误消息(或缺少图像),并且两个地图都显示在正确的位置,但没有显示任何标记。如果重要的话,图像是 32x32px。任何帮助,将不胜感激。

4

1 回答 1

2

在将它们用作标记的地图属性之前,您必须先创建map_1和。map_2

于 2012-09-12T13:00:30.080 回答