Android 용 MapView에서 도로의 색상을 변경하는 방법 (노란색)을 찾고 있습니다. onDraw
메서드를 재정의 한 다음 각 픽셀을 이동하여 변경하는 방법을 생각했지만 방법이 최종적이었습니다.Google지도에서 도로의 색상을 변경하려면 어떻게해야합니까?
ViewGroup로 MapView를 래핑 한 다음 onDraw를 재정의하려고 시도했지만 어떻게해야할지 모르겠습니다.
누구나 아이디어가 있습니까?
감사합니다.
Android 용 MapView에서 도로의 색상을 변경하는 방법 (노란색)을 찾고 있습니다. onDraw
메서드를 재정의 한 다음 각 픽셀을 이동하여 변경하는 방법을 생각했지만 방법이 최종적이었습니다.Google지도에서 도로의 색상을 변경하려면 어떻게해야합니까?
ViewGroup로 MapView를 래핑 한 다음 onDraw를 재정의하려고 시도했지만 어떻게해야할지 모르겠습니다.
누구나 아이디어가 있습니까?
감사합니다.
Google MapView 대신 OpenStreetMap 데이터를 사용하여 osmdroid으로 전환하고 거리 색상 렌더링의 소스 코드를 수정하는 것이 좋습니다.
Maps Android API의 Styled Map 기능을 사용하면 쉽게 (Google지도 API V3.0에서 볼 수있는 순간부터 정확히 알 수 없습니다). JSON 준비 맵 스타일의 경우 Styling Withard을 사용할 수 있습니다. 또한 모든 맵 요소가 아닌 JSON 스타일 객체에 필요한 부분 만 추가 할 수 있습니다. (블루 라벨) 노란색 도로 예를 들어 JSON (/res/raw/map_style.json
)의 경우가 될 수 있습니다
[
{
"featureType": "road",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#ffff00"
}
]
},
{
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#0000ff"
}
]
}
]
및 MainActyvity.java
을지도 조각과 :
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {
private GoogleMap mGoogleMap;
private MapFragment mapFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map_fragment);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
try {
// Customise the styling of the base map using a JSON object defined
// in a raw resource file.
boolean success = mGoogleMap.setMapStyle(
MapStyleOptions.loadRawResourceStyle(
this, R.raw.map_style));
if (!success) {
Log.e(TAG, "Style parsing failed.");
}
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Can't find style. Error: ", e);
}
// Position the map's camera near Sydney, Australia.
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(50.4501,30.5234), 16.0f));
}
}
및 activity_main.xls
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.test.just.googlemapsgeneral.activities.MainActivity">
<fragment
android:id="@+id/map_fragment"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
결과적으로 다음을 얻게됩니다.
또한 정적지도에 대한 스타일의 매개 변수를 추가 할 수 있습니다 당신이있어 요청 https://maps.googleapis.com/maps/api/staticmap?&key=[your_MAPS_API_KEY]¢er=50.4501,30.5234&zoom=16&size=640x640&style=feature:road|element:geometry|color:0xFFFF00
을 위해 : 이
자세한 내용은 Official Blog를 참조하십시오.