একটি মানচিত্র শৈলী

মানচিত্র উপাদানের চেহারা এবং অনুভূতি কাস্টমাইজ করতে, ক্লাউড-ভিত্তিক মানচিত্র স্টাইলিং ব্যবহার করে অথবা সরাসরি কোডে বিকল্পগুলি সেট করে আপনার মানচিত্র স্টাইল করুন।

ক্লাউড-ভিত্তিক মানচিত্র স্টাইলিং ব্যবহার করে মানচিত্রটি স্টাইল করুন

আপনার জাভাস্ক্রিপ্ট কনজিউমার ট্রিপ শেয়ারিং ম্যাপে একটি ম্যাপ স্টাইল প্রয়োগ করতে, JourneySharingMapView তৈরি করার সময় একটি mapId এবং অন্য যেকোনো mapOptions উল্লেখ করুন।

নিম্নলিখিত উদাহরণগুলি দেখায় যে কীভাবে একটি মানচিত্র আইডি দিয়ে একটি মানচিত্র শৈলী প্রয়োগ করতে হয়।

জাভাস্ক্রিপ্ট

const mapView = new google.maps.journeySharing.JourneySharingMapView({
  element: document.getElementById('map_canvas'),
  locationProviders: [locationProvider],
  mapOptions: {
    mapId: 'YOUR_MAP_ID'
  }
  // Any other styling options.
});

টাইপস্ক্রিপ্ট

const mapView = new google.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 দেখুন।

জাভাস্ক্রিপ্ট

const mapView = new google.maps.journeySharing.JourneySharingMapView({
  element: document.getElementById('map_canvas'),
  locationProviders: [locationProvider],
  mapOptions: {
    styles: [
      {
        "featureType": "road.arterial",
        "elementType": "geometry",
        "stylers": [
          { "color": "#CCFFFF" }
        ]
      }
    ]
  }
});

টাইপস্ক্রিপ্ট

const mapView = new google.maps.journeySharing.JourneySharingMapView({
  element: document.getElementById('map_canvas'),
  locationProviders: [locationProvider],
  mapOptions: {
    styles: [
      {
        "featureType": "road.arterial",
        "elementType": "geometry",
        "stylers": [
          { "color": "#CCFFFF" }
        ]
      }
    ]
  }
});

স্বয়ংক্রিয় ফিটিং বন্ধ করুন

আপনি স্বয়ংক্রিয় ফিটিং অক্ষম করে গাড়ি এবং প্রত্যাশিত রুটে ভিউপোর্ট স্বয়ংক্রিয়ভাবে ফিট করা থেকে মানচিত্রটি বন্ধ করতে পারেন। নিম্নলিখিত উদাহরণটি দেখায় যে আপনি যখন যাত্রা ভাগ করে নেওয়ার মানচিত্র দৃশ্য কনফিগার করেন তখন কীভাবে স্বয়ংক্রিয় ফিটিং অক্ষম করবেন।

জাভাস্ক্রিপ্ট

const mapView = new
    google.maps.journeySharing.JourneySharingMapView({
  element: document.getElementById('map_canvas'),
  locationProviders: [locationProvider],
  automaticViewportMode:
      google.maps.journeySharing
          .AutomaticViewportMode.NONE,
  ...
});

টাইপস্ক্রিপ্ট

const mapView = new
    google.maps.journeySharing.JourneySharingMapView({
  element: document.getElementById('map_canvas'),
  locationProviders: [locationProvider],
  automaticViewportMode:
      google.maps.journeySharing
          .AutomaticViewportMode.NONE,
  ...
});

একটি বিদ্যমান মানচিত্র প্রতিস্থাপন করুন

আপনি এমন একটি বিদ্যমান মানচিত্র প্রতিস্থাপন করতে পারেন যাতে মার্কার বা অন্যান্য কাস্টমাইজেশন রয়েছে, সেই কাস্টমাইজেশনগুলি না হারিয়েই।

উদাহরণস্বরূপ, ধরুন আপনার একটি ওয়েব পৃষ্ঠা আছে যার একটি স্ট্যান্ডার্ড google.maps.Map সত্তা রয়েছে যেখানে একটি মার্কার দেখানো হয়েছে:

    <!DOCTYPE html>
    <html>
      <head>
        <style>
           /* Set the size of the div element that contains the map */
          #map {
            height: 400px;  /* The height is 400 pixels */
            width: 100%;  /* The width is the width of the web page */
           }
        </style>
      </head>
      <body>
        <h3>My Google Maps Demo</h3>
        <!--The div element for the map -->
        <div id="map"></div>
        <script>
    // Initialize and add the map
    function initMap() {
      // The location of Pier 39 in San Francisco
      var pier39 = {lat: 37.809326, lng: -122.409981};
      // The map, initially centered at Mountain View, CA.
      var map = new google.maps.Map(document.getElementById('map'));
      map.setOptions({center: {lat: 37.424069, lng: -122.0916944}, zoom: 14});

      // The marker, now positioned at Pier 39
      var marker = new google.maps.Marker({position: pier39, map: map});
    }
        </script>
        <!-- Load the API from the specified URL.
           * The async attribute allows the browser to render the page while the API loads.
           * The key parameter will contain your own API key (which is not needed for this tutorial).
           * The callback parameter executes the initMap() function.
        -->
        <script defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
        </script>
      </body>
    </html>

জাভাস্ক্রিপ্ট ফ্লিট ট্র্যাক লাইব্রেরি যোগ করতে:

  1. প্রমাণীকরণ টোকেন কারখানার জন্য কোড যোগ করুন।
  2. initMap() ফাংশনে একটি অবস্থান প্রদানকারী শুরু করুন।
  3. initMap() ফাংশনে ম্যাপ ভিউ শুরু করুন। ভিউতে ম্যাপ থাকে।
  4. ম্যাপ ভিউ ইনিশিয়ালাইজেশনের জন্য আপনার কাস্টমাইজেশনটি কলব্যাক ফাংশনে সরান।
  5. API লোডারে অবস্থান লাইব্রেরি যোগ করুন।

নির্ধারিত কাজ ব্যবহার করে মানচিত্র প্রতিস্থাপনের উদাহরণ

নিম্নলিখিত উদাহরণগুলি দেখায় যে কীভাবে একটি বিদ্যমান মানচিত্র ব্যবহার করতে হয় যেখানে আপনি একটি নির্ধারিত টাস্ক ব্যবহারের ক্ষেত্রে অবস্থান সরবরাহকারী অবজেক্টটি শুরু করেন। অন-ডিমান্ড ট্রিপ ব্যবহারের ক্ষেত্রে কোডটি একই রকম, তবে আপনি FleetEngineVehicleLocationProvider এর পরিবর্তে FleetEngineDeliveryVehicleLocationProvider ব্যবহার করেন।

    <!DOCTYPE html>
    <html>
      <head>
        <style>
           /* Set the size of the div element that contains the map */
          #map {
            height: 400px;  /* The height is 400 pixels */
            width: 100%;  /* The width is the width of the web page */
           }
        </style>
      </head>
      <body>
        <h3>My Google Maps Demo</h3>
        <!--The div element for the map -->
        <div id="map"></div>
        <script>
    let locationProvider;

    // (1) Authentication Token Fetcher
    function authTokenFetcher(options) {
      // options is a record containing two keys called
      // serviceType and context. The developer should
      // generate the correct SERVER_TOKEN_URL and request
      // based on the values of these fields.
      const response = await fetch(SERVER_TOKEN_URL);
          if (!response.ok) {
            throw new Error(response.statusText);
          }
          const data = await response.json();
          return {
            token: data.Token,
            expiresInSeconds: data.ExpiresInSeconds
          };
    }

    // Initialize and add the map
    function initMap() {
      // (2) Initialize location provider. Use FleetEngineDeliveryVehicleLocationProvider
      // as appropriate.
      locationProvider = new google.maps.journeySharing.FleetEngineDeliveryVehicleLocationProvider({
        YOUR_PROVIDER_ID,
        authTokenFetcher,
      });

      // (3) Initialize map view (which contains the map).
      const mapView = new google.maps.journeySharing.JourneySharingMapView({
        element: document.getElementById('map'),
        locationProviders: [locationProvider],
        // any styling options
      });

    mapView.addListener('ready', () => {
      locationProvider.deliveryVehicleId = DELIVERY_VEHICLE_ID;

        // (4) Add customizations like before.
        // The location of Pier 39 in San Francisco
          var pier39 = {lat: 37.809326, lng: -122.409981};
        // The map, initially centered at Mountain View, CA.
        var map = mapView.map;
        map.setOptions({center: {lat: 37.424069, lng: -122.0916944}, zoom: 14});
        // The marker, now positioned at Pier 39
        var marker = new google.maps.Marker({position: pier39, map: map});
      };
    }
        </script>
        <!-- Load the API from the specified URL
          * The async attribute allows the browser to render the page while the API loads
          * The key parameter will contain your own API key (which is not needed for this tutorial)
          * The callback parameter executes the initMap() function
          *
          * (5) Add the journey sharing library to the API loader, which includes Fleet Tracking functionality.
        -->
        <script defer
        src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap&libraries=journeySharing">
        </script>
      </body>
    </html>

যদি আপনি পিয়ার 39 এর কাছে নির্দিষ্ট আইডি সহ একটি ডেলিভারি গাড়ি পরিচালনা করেন, তাহলে এটি এখন মানচিত্রে রেন্ডার করা হবে।

এরপর কি?