LocationService.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*----------------------------------------------------------------
  2. Copyright (C) 2015 Senparc
  3. 文件名:LocationService.cs
  4. 文件功能描述:地理位置信息处理
  5. 创建标识:Senparc - 20150312
  6. ----------------------------------------------------------------*/
  7. using System.Collections.Generic;
  8. using Senparc.Weixin.MP.Entities;
  9. using Senparc.Weixin.MP.Entities.GoogleMap;
  10. using Senparc.Weixin.MP.Helpers;
  11. namespace Senparc.Weixin.MP.Sample.CommonService
  12. {
  13. public class LocationService
  14. {
  15. public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
  16. {
  17. var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageNews>(requestMessage);
  18. var markersList = new List<GoogleMapMarkers>();
  19. markersList.Add(new GoogleMapMarkers()
  20. {
  21. X = requestMessage.Location_X,
  22. Y = requestMessage.Location_Y,
  23. Color = "red",
  24. Label = "S",
  25. Size = GoogleMapMarkerSize.Default,
  26. });
  27. var mapSize = "480x600";
  28. var mapUrl = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
  29. markersList, mapSize);
  30. responseMessage.Articles.Add(new Article()
  31. {
  32. Description = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
  33. requestMessage.Location_X, requestMessage.Location_Y,
  34. requestMessage.Scale, requestMessage.Label),
  35. PicUrl = mapUrl,
  36. Title = "定位地点周边地图",
  37. Url = mapUrl
  38. });
  39. responseMessage.Articles.Add(new Article()
  40. {
  41. Title = "微信公众平台SDK 官网链接",
  42. Description = "Senparc.Weixin.MK SDK地址",
  43. PicUrl = "http://weixin.senparc.com/images/logo.jpg",
  44. Url = "http://weixin.senparc.com"
  45. });
  46. return responseMessage;
  47. }
  48. }
  49. }