Google 静态地图图标仅适用于部分标记

Google static maps icons only working for a portion of the markers

我正在尝试在 Google 静态地图上绘制一系列标记。由于静态地图 API 不支持 > 10 的标签,我不得不使用数字图像。

由于某些原因,静态地图标记仅使用自定义图像更新了一部分标记,其余为默认标记。我想用自定义图像替换所有默认标记。

这是我的代码,删除了 API 键和敏感数据。

const realtor = require("realtorca");
const unirest = require("unirest");
const nodemailer = require("nodemailer");
const { staticMapUrl } = require("static-google-map");

//https://rapidapi.com/apidojo/api/realtor-canadian-real-estate?endpoint=apiendpoint_bc4d93dd-15c5-47de-b04e-854b2e6176be

var req = unirest(
  "GET",
  "https://realtor-canadian-real-estate.p.rapidapi.com/properties/list-residential"
);

req.query({
  LongitudeMin: -79.44438,
  LongitudeMax: -79.404,
  LatitudeMin: 43.75135,
  LatitudeMax: 43.78448,
  PriceMax: 1500000,
  ZoomLevel: 15,
  BuildingTypeId: 1,
  //NOTE: if there are more than 50 records I need to figure out how to traverse through the pages
  RecordsPerPage: 50,
});

req.headers({
  "x-rapidapi-key": "secret",
  "x-rapidapi-host": "realtor-canadian-real-estate.p.rapidapi.com",
  useQueryString: true,
});

let resultsArray = [];

req.end(function (res) {
  if (res.error) throw new Error(res.error);

  let totalResults = res.body.Paging.TotalRecords;

  let mapObject = {};

  let addMarkers = async function () {
    for (i = 0; i < totalResults; i++) {
      mapObject.markerGroups.push({
        iconURL: `https%3A%2F%2Fapi.geoapify.com%2Fv1%2Ficon%2F%3Ftype%3Dmaterial%26color%3Dred%26icon%3Dcloud%26iconType%3Dawesome%26text%3D${i}%26apiKey%secret`,
        markers: [
          {
            location: {
              lat: res.body.Pins[i].latitude,
              lng: res.body.Pins[i].longitude,
            },
          },
        ],
      });
    }
  };

  mapObject = {
    key: "secret",
    scale: 2,
    size: "1000x1000",
    format: "png",
    markerGroups: [],
  };

  addMarkers();

  let url = staticMapUrl(mapObject);

  //LOGGING TO SEE WHAT HAPPENS
  console.log(totalResults);
  console.log(mapObject);
  console.log(url);

  const forLoop = async (_) => {
    for (let i = 0; i < totalResults; i++) {
      await resultsArray.push(
        "<p>",
        res.body.Results[i].Property.Address.AddressText + "<br />",
        res.body.Results[i].Property.Price + "<br />",
        "Number of bathrooms: " +
          res.body.Results[i].Building.BathroomTotal +
          "<br />",
        "Number of bedrooms: " +
          res.body.Results[i].Building.Bedrooms +
          "<br />",
        "http://www.realtor.ca" +
          res.body.Results[i].RelativeDetailsURL +
          "<br />",
        "Notes: " + res.body.Results[i].PublicRemarks + "</p>"
      );
    }
    console.log(resultsArray);
    console.log(totalResults);

    let transporter = nodemailer.createTransport({
      host: "giow1039.siteground.us",
      port: 587,
      secure: false, // true for 465, false for other ports
      auth: {
        user: "notifications@danielpuiatti.com",
        pass: "secret",
      },
    });

    // send mail with defined transport object
    let info = {
      from: "notifications@danielpuiatti.com", // sender address
      to: "dpuiatti@gmail.com", // list of receivers
      subject: "Hello ✔", // Subject line
      html:
        "<h1>Your daily Realtor.ca update</h1>" +
        String(resultsArray).replace(/,/g, "").replace(/\|/g, " | ") +
        '<img src="' +
        url +
        '" width="800" height="600"/>',
    };

    transporter.sendMail(info, function (err, info) {
      if (err) {
        console.log(err);
        return;
      }
      console.log(info.response);
    });
  };

  forLoop();
});

由于 5 个自定义图标的限制,图标没有更改。我改为用字母字符标记每个点。