Android Consumer SDK v1.0 कस्टमाइज़ेशन के लिए माइग्रेशन

मार्कर कस्टमाइज़ेशन

उपभोक्ता SDK टूल के पुराने वर्शन में, मार्कर स्टाइल प्रॉपर्टी को पसंद के मुताबिक बनाने के लिए, आपने उपभोक्ता SDK टूल के MarkerStyleOptions ऑब्जेक्ट का इस्तेमाल किया था. उपभोक्ता 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 के पुराने वर्शन में, आपने पॉलीलाइन स्टाइल प्रॉपर्टी को पसंद के मुताबिक बनाने के लिए, उपभोक्ता SDK टूल के PolylineStyleOptions ऑब्जेक्ट का इस्तेमाल किया था. उपभोक्ता SDK टूल के 1.0 वर्शन में, बेस पॉलीलाइन स्टाइल प्रॉपर्टी को पसंद के मुताबिक बनाने के लिए Maps SDK टूल के PolylineOptions ऑब्जेक्ट का इस्तेमाल किया जाता है. साथ ही, पॉलीलाइन ट्रैफ़िक के रंगों को पसंद के मुताबिक बनाने के लिए TrafficStyle ऑब्जेक्ट का इस्तेमाल किया जाता है.

ट्रैफ़िक पॉलीलाइन, Consumer SDK v1.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);

अगर अभी तक कोई भी पॉलीलाइन टाइप सेट नहीं किया गया है या स्टाइल के विकल्प null पर सेट हैं, तो ConsumerMapStyle, SDK टूल की डिफ़ॉल्ट स्टाइल के विकल्प दिखाता है. यह बेस 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));