2016-12-10 1 views
0

는 어떻게 프로그래밍 방식으로 자바 스크립트 그들은 내가 작은 지리 클릭이 그림에서중복 기능을 위해 구글은

enter image description here

겹치는 경우 다른 사람의 상단에있는 기능 정의 않는위한 그러나 정보를 매핑 외부 지리학 적 특징이 나타났다. 프로그래밍 방식으로 작은 기능을 맨 위에 배치하고 싶습니다. 여기

는 javascript-

나는 geojson 파일 자체의 기능의 순서를 반전하고이 동작을 변경하지 않았다
map.data.loadGeoJson('<path to my geojson definition>'); 
map.data.setStyle(function (feature) { 
    let color = 'gray'; 
    console.log(feature); 
    if (feature.getProperty('isColorful')) { 
    color = 'blue'; 
    } 
    return ({ 
    fillColor: color, 
    strokeColor: color, 
    strokeWeight: 1 
    }); 
}); 

map.data.addListener('click', function (event) { 
    let name = event.feature.getProperty('name'); 

    let contentString = '<h4>Polygon Info</h4><br>'; 

    contentString += '<p>'; 
    if (name) { 
    contentString += '<b>Name:</b>' + name + '<br>'; 
    }   
    contentString += '</p>'; 

    let infowindow = new google.maps.InfoWindow({ 
    content: contentString, 
    position: event.latLng 
    }); 

    infowindow.open(map); 

    event.feature.setProperty('isColorful', true); 
}); 

주에서지도를 채울 수있는 내 코드입니다.

답변

2
당신은 단지 적절한 값

return ({ 
    fillColor: color, 
    strokeColor: color, 
    strokeWeight: 1, 
    zIndex: zIndex 
}); 

을 해결, 당신은 당신이 setStyle() 기능에서 필요에 따라 Z- 인덱스를 조정할 수 있습니다으로부터 다른 기능 항목을 disinguish 수 feature.Assuming의 z-index 속성을 사용할 수 있습니다

또는 마우스가 입력 될 때 z- 인덱스를 업데이트하십시오.

map.data.addListener('mouseover', function(e) { 
    map.data.overrideStyle(e.feature, { 
    //strokeColor: '#1e3a2a', 
    //strokeWeight: 2, /* can also change these like hover effect */ 
    zIndex: 6 
    }); 
}); 

map.data.addListener('mouseout', function(e) { 
    map.data.revertStyle(); 
});