如何使用.Net将位置数据附加到Mirror Api中的时间轴卡

时间:2013-10-04 07:14:14

标签: asp.net location google-mirror-api google-glass

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

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吗?

1 个答案:

答案 0 :(得分:1)

我找到了附加位置信息的方法。我们可以使用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();