이 문서에서는 지도의 디자인을 맞춤설정하고 데이터 표시 여부 및 뷰포트 옵션을 제어하는 방법을 설명합니다. 다음과 같은 방법으로 이와 같이 지시할 수 있습니다.
클라우드 기반 지도 스타일 사용
자체 코드에서 직접 지도 스타일 옵션 설정
클라우드 기반 지도 스타일 지정으로 지도 스타일 지정
JavaScript 소비자 이동 공유 지도에 지도 스타일을 적용하려면 JourneySharingMapView를 만들 때 mapId 및 기타 mapOptions를 지정합니다.
다음 예에서는 지도 ID를 사용하여 지도 스타일을 적용하는 방법을 보여줍니다.
자바스크립트
constmapView=newgoogle.maps.journeySharing.JourneySharingMapView({element:document.getElementById('map_canvas'),locationProviders:[locationProvider],mapOptions:{mapId:'YOUR_MAP_ID'}// Any other styling options.});
TypeScript
constmapView=newgoogle.maps.journeySharing.JourneySharingMapView({element:document.getElementById('map_canvas'),locationProviders:[locationProvider],mapOptions:{mapId:'YOUR_MAP_ID'}// Any other styling options.});
자체 코드에서 직접 지도 스타일 지정
JourneySharingMapView를 만들 때 지도 옵션을 설정하여 지도 스타일을 맞춤설정할 수도 있습니다. 다음 예에서는 지도 옵션을 사용하여 지도의 스타일을 지정하는 방법을 보여줍니다. 설정할 수 있는 지도 옵션에 관한 자세한 내용은 Google Maps JavaScript API 참조의 mapOptions를 참고하세요.
InfoWindow를 사용하여 차량 또는 위치 마커에 관한 추가 정보를 표시합니다. 자세한 내용은 InfoWindow를 참고하세요.
다음 예에서는 InfoWindow를 만들고 차량 마커에 연결하는 방법을 보여줍니다.
자바스크립트
// 1. Create an info window.constinfoWindow=newgoogle.maps.InfoWindow({disableAutoPan:true});locationProvider.addListener('update',e=>{conststopsCount=e.trip.remainingWaypoints.length;infoWindow.setContent(`Your vehicle is ${stopsCount} stops away.`);// 2. Attach the info window to a vehicle marker.// This property can return multiple markers.constmarker=mapView.vehicleMarkers[0];infoWindow.open(mapView.map,marker);});// 3. Close the info window.infoWindow.close();
TypeScript
// 1. Create an info window.constinfoWindow=newgoogle.maps.InfoWindow({disableAutoPan:true});locationProvider.addListener('update',(e:google.maps.journeySharing.FleetEngineTripLocationProviderUpdateEvent)=>{conststopsCount=e.trip.remainingWaypoints.length;infoWindow.setContent(`Your vehicle is ${stopsCount} stops away.`);// 2. Attach the info window to a vehicle marker.// This property can return multiple markers.constmarker=mapView.vehicleMarkers[0];infoWindow.open(mapView.map,marker);});// 3. Close the info window.infoWindow.close();
자동 맞춤 사용 중지
자동 맞춤을 사용 중지하면 지도가 차량과 예상 경로에 맞게 표시 영역을 자동으로 조정하지 않습니다. 다음 예에서는 이동 경로 공유 지도 뷰를 구성할 때 자동 맞춤을 사용 중지하는 방법을 보여줍니다.
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThis documentation explains how to customize the appearance of maps in journey sharing by using cloud-based map styling or setting style options directly in your code.\u003c/p\u003e\n"],["\u003cp\u003eYou can style maps using cloud-based map styling through the Google Cloud console or by setting style options in your code for \u003ccode\u003eConsumerMapView\u003c/code\u003e and \u003ccode\u003eConsumerMapFragment\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIn JavaScript, you can style your consumer trip sharing map by specifying a \u003ccode\u003emapId\u003c/code\u003e and other \u003ccode\u003emapOptions\u003c/code\u003e when creating the \u003ccode\u003eJourneySharingMapView\u003c/code\u003e, or by directly setting map options in your code.\u003c/p\u003e\n"],["\u003cp\u003eYou can display additional information using \u003ccode\u003eInfoWindow\u003c/code\u003e, and control the viewport by disabling automatic fitting to the vehicle and route.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/mobility/journey-sharing/on-demand/android/style \"View this page for the Android platform docs.\") [iOS](/maps/documentation/mobility/journey-sharing/on-demand/ios/style \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/mobility/journey-sharing/on-demand/javascript/style \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nThis document covers how to customize the look and feel of a map and control\ndata visibility and viewport options. You can do this in the following ways:\n\n- Use cloud-based map styling\n- Set map style options directly in your own code\n\nStyle the map with cloud-based maps styling\n\nTo apply a map style to your JavaScript consumer trip sharing map, specify a\n[`mapId`](/maps/documentation/javascript/reference/map#MapOptions.mapId) and\nany other\n[`mapOptions`](/maps/documentation/javascript/reference/map#MapOptions)\nwhen you create the `JourneySharingMapView`.\n| **Note:** You cannot change or add a `mapId` after the `JourneySharingMapView` has been instantiated.\n\nThe following examples show how to apply a map style with a map ID.\n\n\u003cbr /\u003e\n\nJavaScript\n\n\u003cbr /\u003e\n\n const mapView = new google.maps.journeySharing.JourneySharingMapView({\n element: document.getElementById('map_canvas'),\n locationProviders: [locationProvider],\n mapOptions: {\n mapId: 'YOUR_MAP_ID'\n }\n // Any other styling options.\n });\n\n\u003cbr /\u003e\n\nTypeScript\n\n\u003cbr /\u003e\n\n const mapView = new google.maps.journeySharing.JourneySharingMapView({\n element: document.getElementById('map_canvas'),\n locationProviders: [locationProvider],\n mapOptions: {\n mapId: 'YOUR_MAP_ID'\n }\n // Any other styling options.\n });\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nStyle maps directly in your own code\n\nYou can also customize map styling by setting map options when you create the\n`JourneySharingMapView`. The following examples show how to style a map using\nmap options. For more information on what map options you can set, see\n[`mapOptions`](/maps/documentation/javascript/reference/map#MapOptions)\nin the Google Maps JavaScript API reference.\n\n\u003cbr /\u003e\n\nJavaScript\n\n\u003cbr /\u003e\n\n const mapView = new google.maps.journeySharing.JourneySharingMapView({\n element: document.getElementById('map_canvas'),\n locationProviders: [locationProvider],\n mapOptions: {\n styles: [\n {\n \"featureType\": \"road.arterial\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n { \"color\": \"#CCFFFF\" }\n ]\n }\n ]\n }\n });\n\n\u003cbr /\u003e\n\nTypeScript\n\n\u003cbr /\u003e\n\n const mapView = new google.maps.journeySharing.JourneySharingMapView({\n element: document.getElementById('map_canvas'),\n locationProviders: [locationProvider],\n mapOptions: {\n styles: [\n {\n \"featureType\": \"road.arterial\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n { \"color\": \"#CCFFFF\" }\n ]\n }\n ]\n }\n });\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDisplay information on the map\n\nDisplay additional information about a vehicle or location marker using an\n`InfoWindow`. For more information, see\n[`InfoWindow`](/maps/documentation/javascript/infowindows).\n\nThe following example shows how to create an `InfoWindow` and attach it\nto a vehicle marker: \n\nJavaScript \n\n // 1. Create an info window.\n const infoWindow = new google.maps.InfoWindow(\n {disableAutoPan: true});\n\n locationProvider.addListener('update', e =\u003e {\n const stopsCount = e.trip.remainingWaypoints.length;\n infoWindow.setContent(\n `Your vehicle is ${stopsCount} stops away.`);\n\n // 2. Attach the info window to a vehicle marker.\n // This property can return multiple markers.\n const marker = mapView.vehicleMarkers[0];\n infoWindow.open(mapView.map, marker);\n });\n\n // 3. Close the info window.\n infoWindow.close();\n\nTypeScript \n\n // 1. Create an info window.\n const infoWindow = new google.maps.InfoWindow(\n {disableAutoPan: true});\n\n locationProvider.addListener('update', (e: google.maps.journeySharing.FleetEngineTripLocationProviderUpdateEvent) =\u003e {\n const stopsCount = e.trip.remainingWaypoints.length;\n infoWindow.setContent(\n `Your vehicle is ${stopsCount} stops away.`);\n\n // 2. Attach the info window to a vehicle marker.\n // This property can return multiple markers.\n const marker = mapView.vehicleMarkers[0];\n infoWindow.open(mapView.map, marker);\n });\n\n // 3. Close the info window.\n infoWindow.close();\n\nDisable automatic fitting\n\nYou can stop the map from automatically fitting the viewport to the vehicle\nand anticipated route by disabling automatic fitting. The following example\nshows how to disable automatic fitting when you configure the journey sharing\nmap view. \n\nJavaScript \n\n const mapView = new\n google.maps.journeySharing.JourneySharingMapView({\n element: document.getElementById('map_canvas'),\n locationProviders: [locationProvider],\n automaticViewportMode:\n google.maps.journeySharing\n .AutomaticViewportMode.NONE,\n ...\n });\n\nTypeScript \n\n const mapView = new\n google.maps.journeySharing.JourneySharingMapView({\n element: document.getElementById('map_canvas'),\n locationProviders: [locationProvider],\n automaticViewportMode:\n google.maps.journeySharing\n .AutomaticViewportMode.NONE,\n ...\n });\n\nWhat's next\n\n[Customize markers](/maps/documentation/mobility/journey-sharing/on-demand/javascript/customize-markers)"]]