मार्कर को पसंद के मुताबिक बनाना
Consumer SDK टूल के पुराने वर्शन में, मार्कर स्टाइल प्रॉपर्टी को पसंद के मुताबिक बनाने के लिए, Consumer SDK टूल के MarkerStyleOptions
ऑब्जेक्ट का इस्तेमाल किया जाता था. Consumer SDK v1.0 में, Maps SDK के MarkerOptions
ऑब्जेक्ट का सीधे तौर पर इस्तेमाल किया जाता है.
// Centering the marker anchor at (0.5, 0.5) is recommended.
// For vehicle markers, set flat to true to allow the vehicle marker to freely
// rotate flat on the map (rather than always have it face the camera).
MarkerOptions vehicleMarkerOptions = new MarkerOptions()
.flat(true)
.anchor(0.5f, 0.5f)
.icon(vehicleIcon)
.zIndex(1.0f);
consumerMapStyle.setMarkerStyleOptions(MarkerType.TRIP_VEHICLE);
अगर स्टाइल अब तक सेट नहीं की गई है या स्टाइल के विकल्प null
पर सेट किए गए हैं, तो ConsumerMapStyle
किसी दिए गए मार्कर टाइप के लिए, SDK टूल के तय किए गए डिफ़ॉल्ट स्टाइल विकल्प दिखाता है.
// ConsumerMapStyle returns the SDK-set default style options if none has been set yet.
MarkerOptions defaultPickupPointStyleOptions = consumerMapStyle.getMarkerStyleOptions(MarkerType.PICKUP_POINT);
// Setting the style to null reverts the style back to the SDK-set default properties.
consumerMapStyle.setMarkerStyleOptions(MarkerType.PICKUP_POINT, /* markerStyleOptions= */ null);
MarkerOptions defaultPickupPointStyleOptions = consumerMapStyle.getMarkerStyleOptions(MarkerType.PICKUP_POINT);
अगर आपको नए सिरे से कोई स्टाइल नहीं बनाना है, तो डिफ़ॉल्ट स्टाइल में बदलाव किया जा सकता है. यहां दिए गए उदाहरण में, सिर्फ़ पिकअप आइकॉन में बदलाव किया गया है. साथ ही, मार्कर के बाकी विकल्पों के लिए SDK की डिफ़ॉल्ट सेटिंग का इस्तेमाल किया गया है.
// getMarkerStyleOptions returns the default pickup point style options, since
// the custom style hasn't been set yet.
MarkerOptions pickupPointStyleOptions =
consumerMapStyle.getMarkerStyleOptions(MarkerType.PICKUP_POINT);
// Modify the icon value and set the style.
consumerMapStyle.setMarkerStyleOptions(
pickupPointStyleOptions.icon(pickupPointIcon));
पॉलीलाइन को पसंद के मुताबिक बनाना
Consumer SDK टूल के पुराने वर्शन में, पॉलीलाइन स्टाइल प्रॉपर्टी को पसंद के मुताबिक बनाने के लिए, Consumer SDK टूल के PolylineStyleOptions
ऑब्जेक्ट का इस्तेमाल किया जाता था. Consumer SDK v1.0 में, बुनियादी पॉलीलाइन स्टाइल प्रॉपर्टी को पसंद के मुताबिक बनाने के लिए, Maps SDK के PolylineOptions
ऑब्जेक्ट का इस्तेमाल किया जाता है. साथ ही, पॉलीलाइन के ट्रैफ़िक के रंगों को पसंद के मुताबिक बनाने के लिए, TrafficStyle
ऑब्जेक्ट का इस्तेमाल किया जाता है.
ट्रैफ़िक पॉलीलाइन, Consumer SDK टूल के वर्शन 1.0 के ऐल्फ़ा वैरिएंट में उपलब्ध हैं. अगर ट्रैफ़िक दिखता है, तो ट्रैफ़िक के रंगों से बेस पॉलीलाइन का रंग बदल जाता है. ट्रैफ़िक डिफ़ॉल्ट रूप से नहीं दिखता. TrafficStyle
में ऐसे फ़ील्ड जिनकी वैल्यू सेट नहीं की गई है उनमें SDK की तय की गई डिफ़ॉल्ट वैल्यू भरी जाती हैं.
// PolylineOptions is from Maps SDK
PolylineOptions polylineOptions = new PolylineOptions()
.color(color)
.width(width)
.geodesic(geodesic)
.startCap(startCap)
.endCap(endCap)
.zIndex(zIndex);
consumerMapStyle.setPolylineStyleOptions(
PolylineType.ACTIVE_ROUTE, polylineOptions);
// TrafficStyle is from ConsumerSDK
TrafficStyle trafficStyle = TrafficStyle.builder()
.setTrafficVisibility(true)
.setTrafficColor(SpeedType.NO_DATA, Color.GREY)
.setTrafficColor(SpeedType.NORMAL_VALUE, Color.BLUE)
.setTrafficColor(SpeedType.SLOW_VALUE, Color.ORANGE)
.setTrafficColor(SpeedType.TRAFFIC_JAM, Color.RED)
.build();
consumerMapStyle.setPolylineTrafficStyle(PolylineType.ACTIVE_ROUTE, trafficStyle);
ConsumerMapStyle
, किसी दिए गए पॉलीलाइन टाइप के लिए SDK टूल के डिफ़ॉल्ट स्टाइल विकल्प दिखाता है. ऐसा तब होता है, जब कोई विकल्प सेट न किया गया हो या स्टाइल विकल्प null
पर सेट हों. यह बुनियादी PolylineOptions
और
TrafficStyle
, दोनों पर लागू होता है.
// ConsumerMapStyle returns the SDK's default style options if none has been set yet.
PolylineOptions defaultActiveRouteStyleOptions = consumerMapStyle.getPolylineStyleOptions(PolylineType.ACTIVE_ROUTE);
// Setting the style to null reverts the style back to the SDK-set default properties.
consumerMapStyle.setPolylineStyleOptions(
PolylineType.ACTIVE_ROUTE, /* polylineStyleOptions= */ null);
PolylineOptions defaultActiveRouteStyleOptions =
consumerMapStyle.getPolylineStyleOptions(PolylineType.ACTIVE_ROUTE);
अगर आपको नए सिरे से कोई स्टाइल नहीं बनाना है, तो डिफ़ॉल्ट स्टाइल में बदलाव किया जा सकता है. यहां दिए गए उदाहरण में, सिर्फ़ चालू रूट की बुनियादी पॉलीलाइन के रंग में बदलाव किया गया है. साथ ही, मार्कर के बाकी विकल्पों के लिए, SDK टूल की डिफ़ॉल्ट स्टाइल सेटिंग का इस्तेमाल किया गया है.
// Only customize the remaining route polyline color.
PolylineOptions remainingRouteStyleOptions =
consumerMapStyle.getPolylineStyleOptions(PolylineType.REMAINING_ROUTE);
consumerMapStyle.setPolylineStyleOptions(
remainingRouteStyleOptions.color(Color.DARK_BLUE));