Google Maps v3 - 重叠标记

时间:2014-10-13 20:11:42

标签: google-maps overlap marker

我正在使用Google Maps javascript v3在地图上打印标记,从我的数据库中获取它们。

我需要将标记与另一个标记重叠。例如,我有这样的地图:

enter image description here

我需要在橙色标记上设置绿色标记。

我认为如果我订购查询(ORDER BY)就足够了,但它不起作用。

这是我的javascript函数:

function CargarJson() {
    $.ajax({
        url: '../view/cp_mapconductores_json.php',
        method: 'get',
        cache: false,
        success: function (data) {

            for (var i = 0; i < data.length; i++) {
                var datos = data[i];
                var LatLng = new google.maps.LatLng(datos.latitud, datos.longitud);

                var texto = datos.conductor + " / " + datos.marca + " " + datos.placa;

                var estado = datos.estado;
                var icono;

                if (estado == 0) { //inactivo
                    icono = "../images/taxi-blanco.png";
                } else if (estado == 1) { // disponible
                    icono = "../images/taxi-verde.png";
                } else if (estado == 2) { // ocupado
                    icono = "../images/taxi-naranja.png";
                } else {
                    icono = "../images/taxi-negro.png";
                }


                var marcador = new google.maps.Marker({
                    position: LatLng,
                    map: map,
                    title: texto,
                    icon: icono
                });
                markers.push(marcador);
                var infoWindow = new google.maps.InfoWindow();

                (function (marcador, datos) {
                    google.maps.event.addListener(marcador, 'click', function (e) {
                        infoWindow.setContent('<b>' + datos.conductor + '</b> <br>'
                            + datos.marca + ' ' + datos.placa);
                        infoWindow.open(map, marcador);
                    });
                })(marcador, datos);

            }

        },
        error: function () {
            alert("Se produjo un error en la lectura de datos!");
        }
    });

}

感谢您的回答。

1 个答案:

答案 0 :(得分:1)

使用MarkerOptions

的zIndex属性
  

zIndex |号码|所有标记都按照zIndex的顺序显示在地图上,较高的值显示在具有较低值的标记前面。默认情况下,标记根据其在屏幕上的垂直位置显示,较低的标记出现在屏幕上方的标记前面。

相关问题