如何使用 .Net 将位置数据附加到镜像 API 中的时间线卡



我有位置数据可以使用.Net向用户推送时间轴。我创建位置项并将其分配给时间线项中的位置字段,如以下代码所示。但它没有在时间轴卡中显示任何位置地图或数据。但它显示导航。我需要在卡片上显示位置图像。

MirrorService Service = new MirrorService(new BaseClientService.Initializer()
                                                          {
                                                              Authenticator = Utils.GetAuthenticatorFromState(state)
                                                          });
                TimelineItem timelineItem = new TimelineItem();
                timelineItem.Creator = new Contact()
                                           {
                                               Id = "MEETUP_LOC",
                                               DisplayName = "Meetup Updates",
                                           };

                Location location = new Location() {};
                location.Address = "Voice Lounge, Colombo";
                location.Latitude = 6.887035;
                location.Longitude = 79.866193;
                timelineItem.Location = location;
                timelineItem.Notification = new NotificationConfig() {Level = "DEFAULT"};
                timelineItem.MenuItems = new List<MenuItem>()
                                             {
                                                 new MenuItem() {Action = "NAVIGATE"},
                                                 new MenuItem() {Action = "DELETE"},
                                                 new MenuItem() {Action = "SHARE"},
                                             };
                Service.Timeline.Insert(timelineItem).Fetch();

我如何使用地图图像发送位置数据。我应该使用 HTML 吗?

我想出了附加位置信息的方法。我们可以使用 html 内容将位置数据显示为图像,如以下代码所示。

TimelineItem timelineItem = new TimelineItem();
                timelineItem.Creator = new Contact()
                                           {
                                               Id = "MEETUP_LOC",
                                               DisplayName = "Meetup Updates",
                                           };

                Location location = new Location() {};
                location.DisplayName = "Voice Lounge";
                location.Address = "Voice Lounge, Colombo";
                location.Latitude = 6.887035;
                location.Longitude = 79.866193;

                timelineItem.Html="<article>" +
                                  "<figure>" +
                                  "<img src="glass://map?w=240&h=360&marker=0;" +
                                   location.Latitude +
                                  "," +
                                   location.Longitude +
                                   ""height="360" width="240">" +
                                  "</figure>" +
                                  "<section>" +
                                  "<div class="text-auto-size"><p class="yellow">" +
                                    location.DisplayName +
                                  "</p><p>" +
                                    location.Address +
                                  "</p>" +
                                  "</div>" +
                                  "</section>" +
                                  "</article>";
                timelineItem.Location = location;
                timelineItem.Notification = new NotificationConfig() {Level = "DEFAULT"};
                timelineItem.MenuItems = new List<MenuItem>()
                                             {
                                                 new MenuItem() {Action = "NAVIGATE"},
                                                 new MenuItem() {Action = "DELETE"},
                                                 new MenuItem() {Action = "SHARE"},
                                             };
                Service.Timeline.Insert(timelineItem).Fetch();

最新更新