গ্রাফিক্স দিয়ে মার্কার তৈরি করুন,গ্রাফিক্স দিয়ে মার্কার তৈরি করুন

সম্পূর্ণ উদাহরণ সোর্স কোড দেখুন

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

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

async function initMap() {
    // Request needed libraries.
    const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
    const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
    const { Place } =  await google.maps.importLibrary("places") as google.maps.PlacesLibrary;

    const map = new Map(document.getElementById('map') as HTMLElement, {
        center: { lat: 37.42475, lng: -122.0845 },
        zoom: 13,
        mapId: '4504f8b37365c3d0',
    });

    const parser = new DOMParser();

    // A marker with a custom inline SVG.
    const pinSvgString = '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect width="56" height="56" rx="28" fill="#7837FF"></rect><path d="M46.0675 22.1319L44.0601 22.7843" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.9402 33.2201L9.93262 33.8723" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M27.9999 47.0046V44.8933" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M27.9999 9V11.1113" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M39.1583 43.3597L37.9186 41.6532" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16.8419 12.6442L18.0816 14.3506" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.93262 22.1319L11.9402 22.7843" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M46.0676 33.8724L44.0601 33.2201" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M39.1583 12.6442L37.9186 14.3506" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16.8419 43.3597L18.0816 41.6532" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M28 39L26.8725 37.9904C24.9292 36.226 23.325 34.7026 22.06 33.4202C20.795 32.1378 19.7867 30.9918 19.035 29.9823C18.2833 28.9727 17.7562 28.0587 17.4537 27.2401C17.1512 26.4216 17 25.5939 17 24.7572C17 23.1201 17.5546 21.7513 18.6638 20.6508C19.7729 19.5502 21.1433 19 22.775 19C23.82 19 24.7871 19.2456 25.6762 19.7367C26.5654 20.2278 27.34 20.9372 28 21.8649C28.77 20.8827 29.5858 20.1596 30.4475 19.6958C31.3092 19.2319 32.235 19 33.225 19C34.8567 19 36.2271 19.5502 37.3362 20.6508C38.4454 21.7513 39 23.1201 39 24.7572C39 25.5939 38.8488 26.4216 38.5463 27.2401C38.2438 28.0587 37.7167 28.9727 36.965 29.9823C36.2133 30.9918 35.205 32.1378 33.94 33.4202C32.675 34.7026 31.0708 36.226 29.1275 37.9904L28 39Z" fill="#FF7878"></path></svg>';

    const pinSvg =
        parser.parseFromString(pinSvgString, 'image/svg+xml').documentElement;

    const pinSvgMarkerView = new AdvancedMarkerElement({
        map,
        position: { lat: 37.42475, lng: -122.094 },
        content: pinSvg,
        title: 'A marker using a custom SVG image.',
    });

    // A marker with a with a URL pointing to a PNG.
    const beachFlagImg = document.createElement('img');
    beachFlagImg.src = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';

    const beachFlagMarkerView = new AdvancedMarkerElement({
        map,
        position: { lat: 37.434, lng: -122.082 },
        content: beachFlagImg,
        title: 'A marker using a custom PNG Image',
    });

    // A marker with a custom SVG glyph.
    const glyphImg = document.createElement('img');
    glyphImg.src = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/google_logo_g.svg';

    const glyphSvgPinElement = new PinElement({
        glyph: glyphImg,
    });

    const glyphSvgMarkerView = new AdvancedMarkerElement({
        map,
        position: { lat: 37.425, lng: -122.07 },
        content: glyphSvgPinElement.element,
        title: "A marker using a custom SVG for the glyph.",
    });

    // A marker customized using a place icon and color, name, and geometry.
    const place = new Place({
        id: 'ChIJN5Nz71W3j4ARhx5bwpTQEGg',
    });

    // Call fetchFields, passing the desired data fields.
    await place.fetchFields({ fields: ['location', 'displayName', 'svgIconMaskURI', 'iconBackgroundColor'] });

    const pinElement = new PinElement({
        background: place.iconBackgroundColor,
        glyph: new URL(String(place.svgIconMaskURI)),
    });

    const placeIconMarkerView = new AdvancedMarkerElement({
        map,
        position: place.location,
        content: pinElement.element,
        title: place.displayName,
    });


    // A marker using a Font Awesome icon for the glyph.
    const icon = document.createElement('div');
    icon.innerHTML = '<i class="fa fa-pizza-slice fa-lg"></i>';
    const faPin = new PinElement({
        glyph: icon,
        glyphColor: '#ff8300',
        background: '#FFD514',
        borderColor: '#ff8300',
    });

    const faMarker = new AdvancedMarkerElement({
        map,
        position: { lat: 37.412, lng: -122.095829650878 },
        content: faPin.element,
        title: 'A marker using a FontAwesome icon for the glyph.'
    });
}

initMap();

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

async function initMap() {
  // Request needed libraries.
  const { Map } = await google.maps.importLibrary("maps");
  const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary(
    "marker",
  );
  const { Place } = await google.maps.importLibrary("places");
  const map = new Map(document.getElementById("map"), {
    center: { lat: 37.42475, lng: -122.0845 },
    zoom: 13,
    mapId: "4504f8b37365c3d0",
  });
  const parser = new DOMParser();
  // A marker with a custom inline SVG.
  const pinSvgString =
    '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect width="56" height="56" rx="28" fill="#7837FF"></rect><path d="M46.0675 22.1319L44.0601 22.7843" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.9402 33.2201L9.93262 33.8723" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M27.9999 47.0046V44.8933" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M27.9999 9V11.1113" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M39.1583 43.3597L37.9186 41.6532" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16.8419 12.6442L18.0816 14.3506" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.93262 22.1319L11.9402 22.7843" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M46.0676 33.8724L44.0601 33.2201" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M39.1583 12.6442L37.9186 14.3506" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16.8419 43.3597L18.0816 41.6532" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M28 39L26.8725 37.9904C24.9292 36.226 23.325 34.7026 22.06 33.4202C20.795 32.1378 19.7867 30.9918 19.035 29.9823C18.2833 28.9727 17.7562 28.0587 17.4537 27.2401C17.1512 26.4216 17 25.5939 17 24.7572C17 23.1201 17.5546 21.7513 18.6638 20.6508C19.7729 19.5502 21.1433 19 22.775 19C23.82 19 24.7871 19.2456 25.6762 19.7367C26.5654 20.2278 27.34 20.9372 28 21.8649C28.77 20.8827 29.5858 20.1596 30.4475 19.6958C31.3092 19.2319 32.235 19 33.225 19C34.8567 19 36.2271 19.5502 37.3362 20.6508C38.4454 21.7513 39 23.1201 39 24.7572C39 25.5939 38.8488 26.4216 38.5463 27.2401C38.2438 28.0587 37.7167 28.9727 36.965 29.9823C36.2133 30.9918 35.205 32.1378 33.94 33.4202C32.675 34.7026 31.0708 36.226 29.1275 37.9904L28 39Z" fill="#FF7878"></path></svg>';
  const pinSvg = parser.parseFromString(
    pinSvgString,
    "image/svg+xml",
  ).documentElement;
  const pinSvgMarkerView = new AdvancedMarkerElement({
    map,
    position: { lat: 37.42475, lng: -122.094 },
    content: pinSvg,
    title: "A marker using a custom SVG image.",
  });
  // A marker with a with a URL pointing to a PNG.
  const beachFlagImg = document.createElement("img");

  beachFlagImg.src =
    "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png";

  const beachFlagMarkerView = new AdvancedMarkerElement({
    map,
    position: { lat: 37.434, lng: -122.082 },
    content: beachFlagImg,
    title: "A marker using a custom PNG Image",
  });
  // A marker with a custom SVG glyph.
  const glyphImg = document.createElement("img");

  glyphImg.src =
    "https://developers.google.com/maps/documentation/javascript/examples/full/images/google_logo_g.svg";

  const glyphSvgPinElement = new PinElement({
    glyph: glyphImg,
  });
  const glyphSvgMarkerView = new AdvancedMarkerElement({
    map,
    position: { lat: 37.425, lng: -122.07 },
    content: glyphSvgPinElement.element,
    title: "A marker using a custom SVG for the glyph.",
  });
  // A marker customized using a place icon and color, name, and geometry.
  const place = new Place({
    id: "ChIJN5Nz71W3j4ARhx5bwpTQEGg",
  });

  // Call fetchFields, passing the desired data fields.
  await place.fetchFields({
    fields: [
      "location",
      "displayName",
      "svgIconMaskURI",
      "iconBackgroundColor",
    ],
  });

  const pinElement = new PinElement({
    background: place.iconBackgroundColor,
    glyph: new URL(String(place.svgIconMaskURI)),
  });
  const placeIconMarkerView = new AdvancedMarkerElement({
    map,
    position: place.location,
    content: pinElement.element,
    title: place.displayName,
  });
  // A marker using a Font Awesome icon for the glyph.
  const icon = document.createElement("div");

  icon.innerHTML = '<i class="fa fa-pizza-slice fa-lg"></i>';

  const faPin = new PinElement({
    glyph: icon,
    glyphColor: "#ff8300",
    background: "#FFD514",
    borderColor: "#ff8300",
  });
  const faMarker = new AdvancedMarkerElement({
    map,
    position: { lat: 37.412, lng: -122.095829650878 },
    content: faPin.element,
    title: "A marker using a FontAwesome icon for the glyph.",
  });
}

initMap();

সিএসএস

/* 
 * Always set the map height explicitly to define the size of the div element
 * that contains the map. 
 */
#map {
  height: 100%;
}

/* 
 * Optional: Makes the sample page fill the window. 
 */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

এইচটিএমএল

<html>
  <head>
    <title>Advanced Markers Using Graphics</title>

    <script src="https://use.fontawesome.com/releases/v5.15.4/js/all.js"></script>

    <link rel="stylesheet" type="text/css" href="./style.css" />
    <script type="module" src="./index.js"></script>
  </head>
  <body>
    <div id="map"></div>

    <!-- prettier-ignore -->
    <script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
        ({key: "AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg", v: "beta"});</script>
  </body>
</html>

নমুনা চেষ্টা করুন

উন্নত মার্কার API একটি কাস্টম গ্রাফিক চিত্রের সাথে ডিফল্ট মার্কার আইকন প্রতিস্থাপন সমর্থন করে। আপনি একটি ইমেজ ফাইল দিয়ে গ্লিফ প্রতিস্থাপন করতে পারেন। এই পৃষ্ঠাটি আপনাকে দেখায় কিভাবে:

উন্নত মার্কার PNG, JPEG, GIF, SVG, এবং TIFF সহ সমস্ত সাধারণ ইমেজ ফাইলের ধরনকে সমর্থন করে।

একটি মানচিত্রে মার্কার যোগ করার জন্য, আপনাকে প্রথমে marker লাইব্রেরি লোড করতে হবে যা AdvancedMarkerElement এবং PinElement ক্লাস প্রদান করে।

একটি কাস্টম গ্রাফিক ফাইল ব্যবহার করুন

AdvancedMarkerElement.content বিকল্পে একটি গ্রাফিক ফাইল (উদাহরণস্বরূপ PNG) উল্লেখ করে একটি img উপাদান পাস করে একটি কাস্টম চিত্র ব্যবহার করে একটি মার্কার তৈরি করুন:

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

// A marker with a with a URL pointing to a PNG.
const beachFlagImg = document.createElement('img');
beachFlagImg.src = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';

const beachFlagMarkerView = new AdvancedMarkerElement({
    map,
    position: { lat: 37.434, lng: -122.082 },
    content: beachFlagImg,
    title: 'A marker using a custom PNG Image',
});

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

// A marker with a with a URL pointing to a PNG.
const beachFlagImg = document.createElement("img");

beachFlagImg.src =
  "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png";

const beachFlagMarkerView = new AdvancedMarkerElement({
  map,
  position: { lat: 37.434, lng: -122.082 },
  content: beachFlagImg,
  title: "A marker using a custom PNG Image",
});

একটি ইনলাইন SVG ব্যবহার করুন

কিছু পরিস্থিতিতে একটি ইনলাইন SVG ব্যবহারের জন্য কল করতে পারে। AdvancedMarkerElement.content বিকল্পে একটি SVG XML উপাদান পাস করে একটি ইনলাইন SVG চিত্র ব্যবহার করে একটি মার্কার তৈরি করুন:

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

const parser = new DOMParser();

// A marker with a custom inline SVG.
const pinSvgString = '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect width="56" height="56" rx="28" fill="#7837FF"></rect><path d="M46.0675 22.1319L44.0601 22.7843" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.9402 33.2201L9.93262 33.8723" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M27.9999 47.0046V44.8933" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M27.9999 9V11.1113" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M39.1583 43.3597L37.9186 41.6532" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16.8419 12.6442L18.0816 14.3506" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.93262 22.1319L11.9402 22.7843" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M46.0676 33.8724L44.0601 33.2201" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M39.1583 12.6442L37.9186 14.3506" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16.8419 43.3597L18.0816 41.6532" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M28 39L26.8725 37.9904C24.9292 36.226 23.325 34.7026 22.06 33.4202C20.795 32.1378 19.7867 30.9918 19.035 29.9823C18.2833 28.9727 17.7562 28.0587 17.4537 27.2401C17.1512 26.4216 17 25.5939 17 24.7572C17 23.1201 17.5546 21.7513 18.6638 20.6508C19.7729 19.5502 21.1433 19 22.775 19C23.82 19 24.7871 19.2456 25.6762 19.7367C26.5654 20.2278 27.34 20.9372 28 21.8649C28.77 20.8827 29.5858 20.1596 30.4475 19.6958C31.3092 19.2319 32.235 19 33.225 19C34.8567 19 36.2271 19.5502 37.3362 20.6508C38.4454 21.7513 39 23.1201 39 24.7572C39 25.5939 38.8488 26.4216 38.5463 27.2401C38.2438 28.0587 37.7167 28.9727 36.965 29.9823C36.2133 30.9918 35.205 32.1378 33.94 33.4202C32.675 34.7026 31.0708 36.226 29.1275 37.9904L28 39Z" fill="#FF7878"></path></svg>';

const pinSvg =
    parser.parseFromString(pinSvgString, 'image/svg+xml').documentElement;

const pinSvgMarkerView = new AdvancedMarkerElement({
    map,
    position: { lat: 37.42475, lng: -122.094 },
    content: pinSvg,
    title: 'A marker using a custom SVG image.',
});

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

const parser = new DOMParser();
// A marker with a custom inline SVG.
const pinSvgString =
  '<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 56 56" fill="none"><rect width="56" height="56" rx="28" fill="#7837FF"></rect><path d="M46.0675 22.1319L44.0601 22.7843" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.9402 33.2201L9.93262 33.8723" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M27.9999 47.0046V44.8933" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M27.9999 9V11.1113" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M39.1583 43.3597L37.9186 41.6532" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16.8419 12.6442L18.0816 14.3506" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.93262 22.1319L11.9402 22.7843" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M46.0676 33.8724L44.0601 33.2201" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M39.1583 12.6442L37.9186 14.3506" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M16.8419 43.3597L18.0816 41.6532" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M28 39L26.8725 37.9904C24.9292 36.226 23.325 34.7026 22.06 33.4202C20.795 32.1378 19.7867 30.9918 19.035 29.9823C18.2833 28.9727 17.7562 28.0587 17.4537 27.2401C17.1512 26.4216 17 25.5939 17 24.7572C17 23.1201 17.5546 21.7513 18.6638 20.6508C19.7729 19.5502 21.1433 19 22.775 19C23.82 19 24.7871 19.2456 25.6762 19.7367C26.5654 20.2278 27.34 20.9372 28 21.8649C28.77 20.8827 29.5858 20.1596 30.4475 19.6958C31.3092 19.2319 32.235 19 33.225 19C34.8567 19 36.2271 19.5502 37.3362 20.6508C38.4454 21.7513 39 23.1201 39 24.7572C39 25.5939 38.8488 26.4216 38.5463 27.2401C38.2438 28.0587 37.7167 28.9727 36.965 29.9823C36.2133 30.9918 35.205 32.1378 33.94 33.4202C32.675 34.7026 31.0708 36.226 29.1275 37.9904L28 39Z" fill="#FF7878"></path></svg>';
const pinSvg = parser.parseFromString(
  pinSvgString,
  "image/svg+xml",
).documentElement;
const pinSvgMarkerView = new AdvancedMarkerElement({
  map,
  position: { lat: 37.42475, lng: -122.094 },
  content: pinSvg,
  title: "A marker using a custom SVG image.",
});

গ্লিফ হিসাবে একটি গ্রাফিক ফাইল ব্যবহার করুন

PinElement.glyph বিকল্পে একটি গ্রাফিক ফাইল রিসোর্স বা একটি ইনলাইন SVG রিসোর্স উল্লেখ করে একটি img উপাদান পাস করে ডিফল্ট গ্লাইফ প্রতিস্থাপন করুন:

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

// A marker with a custom SVG glyph.
const glyphImg = document.createElement('img');
glyphImg.src = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/google_logo_g.svg';

const glyphSvgPinElement = new PinElement({
    glyph: glyphImg,
});

const glyphSvgMarkerView = new AdvancedMarkerElement({
    map,
    position: { lat: 37.425, lng: -122.07 },
    content: glyphSvgPinElement.element,
    title: "A marker using a custom SVG for the glyph.",
});

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

// A marker with a custom SVG glyph.
const glyphImg = document.createElement("img");

glyphImg.src =
  "https://developers.google.com/maps/documentation/javascript/examples/full/images/google_logo_g.svg";

const glyphSvgPinElement = new PinElement({
  glyph: glyphImg,
});
const glyphSvgMarkerView = new AdvancedMarkerElement({
  map,
  position: { lat: 37.425, lng: -122.07 },
  content: glyphSvgPinElement.element,
  title: "A marker using a custom SVG for the glyph.",
});

গ্লিফ হিসাবে একটি স্থান আইকন ব্যবহার করুন

স্থানের বিবরণ দিয়ে, আপনি একটি স্থান আইকন এবং পটভূমির রঙের জন্য অনুরোধ করতে পারেন, যা আপনি মার্কারগুলিতে প্রয়োগ করতে পারেন৷ PinElement.background বিকল্পে place.icon_background_color পাস করে স্থান ডেটা ব্যবহার করে একটি মার্কার কাস্টমাইজ করুন, এবং PinElement.glyphplace.icon_mask_base_uri ব্যবহার করে একটি URL। URI-তে .png বা .svg ফাইল টাইপ এক্সটেনশন যোগ করুন। সঠিক অবস্থানে মার্কার স্থাপন করতে place.geometry.location ব্যবহার করুন। এই উদাহরণটি চিহ্নিতকারী শিরোনামে place.name ও প্রদর্শন করে।

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

// A marker customized using a place icon and color, name, and geometry.
const place = new Place({
    id: 'ChIJN5Nz71W3j4ARhx5bwpTQEGg',
});

// Call fetchFields, passing the desired data fields.
await place.fetchFields({ fields: ['location', 'displayName', 'svgIconMaskURI', 'iconBackgroundColor'] });

const pinElement = new PinElement({
    background: place.iconBackgroundColor,
    glyph: new URL(String(place.svgIconMaskURI)),
});

const placeIconMarkerView = new AdvancedMarkerElement({
    map,
    position: place.location,
    content: pinElement.element,
    title: place.displayName,
});

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

// A marker customized using a place icon and color, name, and geometry.
const place = new Place({
  id: "ChIJN5Nz71W3j4ARhx5bwpTQEGg",
});

// Call fetchFields, passing the desired data fields.
await place.fetchFields({
  fields: [
    "location",
    "displayName",
    "svgIconMaskURI",
    "iconBackgroundColor",
  ],
});

const pinElement = new PinElement({
  background: place.iconBackgroundColor,
  glyph: new URL(String(place.svgIconMaskURI)),
});
const placeIconMarkerView = new AdvancedMarkerElement({
  map,
  position: place.location,
  content: pinElement.element,
  title: place.displayName,
});

আইকন ফন্ট ব্যবহার করুন

একটি HTML <i> ট্যাগে আইকনের নাম এবং স্টাইল সিএসএস ক্লাস হিসাবে যোগ করে এবং একটি <div> ট্যাগে যোগ করে মার্কার সহ আইকন ফন্ট ব্যবহার করুন, যেমন ফন্ট অসাধারন। নিম্নলিখিত উদাহরণে আইকনটি গ্লিফ প্রতিস্থাপন করতে ব্যবহৃত হয়:

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

// A marker using a Font Awesome icon for the glyph.
const icon = document.createElement('div');
icon.innerHTML = '<i class="fa fa-pizza-slice fa-lg"></i>';
const faPin = new PinElement({
    glyph: icon,
    glyphColor: '#ff8300',
    background: '#FFD514',
    borderColor: '#ff8300',
});

const faMarker = new AdvancedMarkerElement({
    map,
    position: { lat: 37.412, lng: -122.095829650878 },
    content: faPin.element,
    title: 'A marker using a FontAwesome icon for the glyph.'
});

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

// A marker using a Font Awesome icon for the glyph.
const icon = document.createElement("div");

icon.innerHTML = '<i class="fa fa-pizza-slice fa-lg"></i>';

const faPin = new PinElement({
  glyph: icon,
  glyphColor: "#ff8300",
  background: "#FFD514",
  borderColor: "#ff8300",
});
const faMarker = new AdvancedMarkerElement({
  map,
  position: { lat: 37.412, lng: -122.095829650878 },
  content: faPin.element,
  title: "A marker using a FontAwesome icon for the glyph.",
});

পূর্ববর্তী উদাহরণে, প্রয়োজনীয় ফন্ট অসাধারণ স্ক্রিপ্টটি HTML ফাইলের script উপাদানের মাধ্যমে লোড করা হয়েছে:

<script src="https://use.fontawesome.com/releases/v6.2.0/js/all.js"></script>

পরবর্তী পদক্ষেপ

কাস্টম HTML দিয়ে মার্কার তৈরি করুন