해결 방법은 같은 위치에 마커를 표시하는 것입니다 조금 비트 맵을 따로 따로 분리하여 사용자가 여러 마커에 대해 약간의 아이디어를 얻을 수 있도록합니다.
지도상의 마커와 그 위치를지도에 기록하고지도에 마커를 추가 할 때마다 동일한 위치에 다른 마커가 표시되지 않도록합니다. 그렇다면 추가하려는 새 마커의 위치에 오프셋을 추가합니다.
static final float COORDINATE_OFFSET = 0.00002f; // You can change this value according to your need
아래 방법은 새 마커에 사용해야하는 위치를 반환합니다. 이 메서드는 새로운 마커의 현재 위도와 경도를 매개 변수로 사용합니다.
// Check if any marker is displayed on given coordinate. If yes then decide
// another appropriate coordinate to display this marker. It returns an
// array with latitude(at index 0) and longitude(at index 1).
private String[] coordinateForMarker(float latitude, float longitude) {
String[] location = new String[2];
for (int i = 0; i <= MAX_NUMBER_OF_MARKERS; i++) {
if (mapAlreadyHasMarkerForLocation((latitude + i
* COORDINATE_OFFSET)
+ "," + (longitude + i * COORDINATE_OFFSET))) {
// If i = 0 then below if condition is same as upper one. Hence, no need to execute below if condition.
if (i == 0)
continue;
if (mapAlreadyHasMarkerForLocation((latitude - i
* COORDINATE_OFFSET)
+ "," + (longitude - i * COORDINATE_OFFSET))) {
continue;
} else {
location[0] = latitude - (i * COORDINATE_OFFSET) + "";
location[1] = longitude - (i * COORDINATE_OFFSET) + "";
break;
}
} else {
location[0] = latitude + (i * COORDINATE_OFFSET) + "";
location[1] = longitude + (i * COORDINATE_OFFSET) + "";
break;
}
}
return location;
}
// Return whether marker with same location is already on map
private boolean mapAlreadyHasMarkerForLocation(String location) {
return (markerLocation.containsValue(location));
}
위의 코드에서 markerLocation
은 HashMap입니다.
HashMap<String, String> markerLocation; // HashMap of marker identifier and its location as a string
이 답변에는 Android 용 코드가 있지만 iOS에는 동일한 로직이 적용됩니다.
목록보기를 표시하고 싶지 않다면 그게 정말로 유일한 옵션입니다. – tyczj
@tyczj 다른 사람들이 멀티플 마커를 설명하기 위해 왼쪽/오른쪽으로 기울어 진 마커 아이콘을 표시하는 등의 다른 해결책을 찾고 있습니다. 같은 지점에. 또는 다른 사람 주위에 어떤 다른 작품을 가지고 있습니다. – Geek
안녕하세요, mapView.List에 같은 위치에있는 표식을 확장하거나 표시하려면이 방법을 구현할 수 있습니까? 다음과 같이 구현하고 싶습니다. http://jawj.github.io/OverlappingMarkerSpiderfier/demo.html – AndiM