문제 설명
Android Google 지도는 GeoJSON을 사용하여 마커를 설정합니다. (Android Google Maps set marker using GeoJSON)
내 Android 애플리케이션 내에서 GeoJSON Marker를 사용하고 싶습니다. 더 구체적으로 이 기호는 코드에서 marker‑symbol로 설명되어 있습니다. 각 기능의 제목을 따로따로 얻을 수는 있지만, marker‑symbol은 변경되지 않고 아래와 같이 빨간색 기본값으로 유지됩니다. 마커 아이콘을 변경하는 방법을 아는 사람이 있습니까?
GeoJSON 마커:
일반 기본 마커:
참조 솔루션
방법 1:
You need to provide the styling function in order to create a custom markers while using GeoJson. Styling function are mostly used to apply styles on a specific feature like marker.
For example this is your Json Data:
{
"type": "MarkerCollection",
"features": [
{
"type": "Marker",
"geometry": {
"type": "Point",
"icon": "/static/images/icons/map‑marker‑do.png",
"coordinates": [
‑10.45893,
23.8574
]
},
"properties": {
"name": "Restaurant",
"description": "Best Restaurant to eat Italian",
"icon": "/static/images/icons/map‑marker‑do.png"
}
}
]
}
The styling code would be:
map.data.setStyle(function(marker) {
return {icon:feature.getProperty('icon')};
});