Ejemplo n.º 1
0
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);

            var markersList = new List <Markers>();

            markersList.Add(new Markers()
            {
                X     = requestMessage.Location_X,
                Y     = requestMessage.Location_Y,
                Color = "red",
                Label = "S",
                Size  = MarkerSize.Default,
            });
            var mapSize = "480x600";
            var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/, markersList, size: mapSize);

            responseMessage.Articles.Add(new Article()
            {
                Description = requestMessage.Label,
                PicUrl      = mapUrl,
                Title       = "定位地点周边地图",
                Url         = mapUrl
            });
            responseMessage.Articles.Add(new Article()
            {
                Title       = "美天网络统一帐号管理系统",
                Description = "美天网络统一帐号管理系统",
                PicUrl      = "http://www.xba.com.cn/NewPassLogin3/logo4.jpg",
                Url         = "http://www.xba.com.cn"
            });
            responseMessage.Content = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}", requestMessage.Location_X, requestMessage.Location_Y, requestMessage.Scale, requestMessage.Label);
            return(responseMessage);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Combine both A -&gt; Z and Round Trip with optimize by many algorithm and distance,
        ///     duration by Google Matrix
        /// </summary>
        /// <param name="coordinates"> </param>
        /// <param name="mode">        </param>
        /// <param name="googleApiKey">
        ///     Use for FastestTripMode.RoundTrip - Optional, method still work without key but have
        ///     limitation by Google Policy.
        /// </param>
        /// <remarks>
        ///     Concorde TSP Solver algorithm combine with Ant colony optimization algorithms to find
        ///     wayCoordinate and best path
        /// </remarks>
        public FastestTrip(IReadOnlyCollection <Models.Coordinate> coordinates, FastestTripMode mode = FastestTripMode.AtoZ, string googleApiKey = "")
        {
            if (coordinates.Count < 1)
            {
                throw new NotSupportedException();
            }

            _tripMode = mode;

            _googleApiKey = googleApiKey;

            Coordinates = new List <Models.Coordinate>();

            Coordinates.AddRange(coordinates);

            // Get Distance Duration Matrix

            var coordinateModels = Coordinates.Select(x => new CoordinateModel(x.Longitude, x.Latitude)).ToArray();

            var getDistanceDurationMatrixTask = GoogleMapHelper.GetDistanceDurationMatrixAsync(coordinateModels, coordinateModels, googleApiKey: _googleApiKey);

            getDistanceDurationMatrixTask.Wait();

            DistanceDurationDurationMatrix = getDistanceDurationMatrixTask.Result;

            // Start Calculate Trip

            CalculateTrip(mode);
        }
        public string GetMapUri(float latitude, float longitude, int zoom, int scale, int width, int height, GoogleMapType mapType, GoogleImageFormat format, IList <TrackCoordinate> trackCoordinates)
        {
            var requestUri = string.Empty;

            for (int i = _resolutionModifierStep; i <= _maxResolutionModifierStep; i++)
            {
                if (i > _resolutionModifierStep)
                {
                    _logger.LogTrace($"Attempting to build Track Map requestUri at resolution of {i}");
                }
                string pathParameter = BuildMapPath(trackCoordinates, i);

                requestUri = string.Format(
                    "https://maps.googleapis.com/maps/api/staticmap?center={0}&zoom={1}&size={2}&maptype={3}&format={4}{5}&key={6}",
                    $"{latitude},{longitude}",
                    zoom,
                    $"{width}x{height}",
                    GoogleMapHelper.GetGoogleMapTypeString(mapType),
                    GoogleMapHelper.GetGoogleFormatString(format),
                    pathParameter,
                    GoogleMapHelper.ApiKey);

                if (requestUri.Length < 8192)
                {
                    break;
                }
                else if (requestUri.Length > 8192 && i >= _maxResolutionModifierStep)
                {
                    throw new InvalidOperationException($"requestUri too long: {requestUri.Length}");
                }
            }

            return(requestUri);
        }
Ejemplo n.º 4
0
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);
            var markerList      = new List <GoogleMapMarkers>();

            markerList.Add(new GoogleMapMarkers()
            {
                X     = requestMessage.Location_X,
                Y     = requestMessage.Location_Y,
                Color = "red",
                Label = "s",
                Size  = GoogleMapMarkerSize.Default,
            });
            var mapSize = "480x600";
            var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19, markerList, mapSize);

            responseMessage.Articles.Add(new Article()
            {
                Description = string.Format("你的地理位置处于:Localtion_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                            requestMessage.Location_X, requestMessage.Location_Y,
                                            requestMessage.Scale, requestMessage.Label),
                PicUrl = "http://1p623v6690.iok.la/2.jpg",
                Url    = "http://baidu.com"
            });
            return(responseMessage);
        }
Ejemplo n.º 5
0
        //algorithm 0
        //for new algorthm need mimic bellow and replace GoogleMapHelper() to ur new function
        public void GoogleMap(int AlgorithmId)
        {
            while (true)
            {
                bool continue1 = startCheck();
                while (continue1)
                {
                    TwittersI ts = new Twitters();
                    ts.allTweets = database.loadBasicTweets(algorithmInfomations[AlgorithmId].lastMaxId + 1, this.TweetbnumberEachCycle);
                    if (ts.allTweets.Count != 0)//if nothing is loaded not run
                    {
                        //for new algorthm need to replace GoogleMapHelper() to ur new function
                        LocationHelper ghp = new GoogleMapHelper();


                        TwitterModel id = ghp.run(ts, AlgorithmId);
                        algorithmInfomations[AlgorithmId].lastMaxId = id.realTwitterId;
                        algorithmInfomations[AlgorithmId].lastDate  = id.createAt;
                        ts.saveLocationInTweets(AlgorithmId);
                        database.updateAlgorithmInfo(algorithmInfomations[AlgorithmId]);
                    }
                    else
                    {
                        continue1 = false;
                    }
                }
                Thread.Sleep(sleepInterval); // wait for sleepInterval, then continue
            }
        }
Ejemplo n.º 6
0
        private void buttonGoogleQueryRoute_Click(object sender, EventArgs e)
        {
            try
            {
                MapRoute.StartName = textGoogleMapsFrom.Text;
                MapRoute.EndName   = textGoogleMapsTo.Text;

                if (!GoogleMapHelper.GetRoute(textGoogleMapsKey.Text, textGoogleMapsFrom.Text, textGoogleMapsTo.Text,
                                              out SimioMapRoute mapRoute,
                                              out string requestUrl, out string explanation))
                {
                    alert($"Cannot get Route. Err={explanation}");
                    return;
                }

                MapRoute = mapRoute;

                textGoogleMapsRequestUrl.Text = requestUrl;
                textGoogleMapsResponse.Text   = explanation;
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"QueryBingMaps Error={ex}");
            }
        }
Ejemplo n.º 7
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => (ViewModel as BaseChallengesViewModel).Challenge))
     {
         if ((ViewModel as BaseChallengesViewModel).Challenge != null && (ViewModel as BaseChallengesViewModel).Challenge.LocationLat != null && (ViewModel as BaseChallengesViewModel).Challenge.LocationLong != null && _map != null)
         {
             //ViewModel.RequiredLocation = true;
             GoogleMapHelper.UpdateMapZoom(_map, ViewModel.Challenge.LocationLat.Value, ViewModel.Challenge.LocationLong.Value, ViewModel.Challenge.RadiusMeters);
         }
         //else
         //    ViewModel.RequiredLocation = false;
     }
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.SubmitButtonAnimated))
     {
         if (ViewModel.SubmitButtonAnimated)
         {
             AnimateButton(button, Resource.Drawable.ic_loadingIndicator);
         }
         if (!ViewModel.SubmitButtonAnimated)
         {
             button.SetImageResource(Resource.Drawable.challenges_postering_btn);
             button.ClearAnimation();
         }
     }
 }
Ejemplo n.º 8
0
        public void GetGoogleStaticMapTest()
        {
            var markersList = new List <Markers>();

            markersList.Add(new Markers()
            {
                X     = 31.285774,
                Y     = 120.597610,
                Color = "red",
                Label = "O",
                Size  = MarkerSize.Default,
            });
            markersList.Add(new Markers()
            {
                X     = 31.289774,
                Y     = 120.597910,
                Color = "blue",
                Label = "T",
                Size  = MarkerSize.Default,
            });

            var url = GoogleMapHelper.GetGoogleStaticMap(19, markersList, size: "640x640");

            Console.WriteLine(url);
            Assert.IsNotNull(url);
        }
Ejemplo n.º 9
0
        public void DrawProfilesModule()
        {
            Profiles.Profile.Utilities.DataIO data = new Profiles.Profile.Utilities.DataIO();

            if (Request.QueryString["Subject"] == null)
            {
                return;
            }

            base.RDFTriple = new RDFTriple(Convert.ToInt64(Request.QueryString["Subject"]));



            dlGoogleMapLinks.DataSource = data.GetGoogleMapZoomLinks();
            dlGoogleMapLinks.DataBind();

            SqlDataReader reader  = null;
            SqlDataReader reader2 = null;

            Profiles.Framework.Utilities.SessionManagement session = new SessionManagement();

            GoogleMapHelper gmh = new GoogleMapHelper();

            if (base.GetModuleParamString("MapType") == "CoAuthor")
            {
                reader  = data.GetGMapUserCoAuthors(base.RDFTriple.Subject, 0, session.Session().SessionID);
                reader2 = data.GetGMapUserCoAuthors(base.RDFTriple.Subject, 1, session.Session().SessionID);
            }

            if (base.GetModuleParamString("MapType") == "SimilarTo")
            {
                reader  = data.GetGMapUserSimilarPeople(base.RDFTriple.Subject, false, session.Session().SessionID);
                reader2 = data.GetGMapUserSimilarPeople(base.RDFTriple.Subject, true, session.Session().SessionID);
            }

            if (base.GetModuleParamString("MapType") == "Group")
            {
                litCoauthorGroup.Text = "group members";
                reader  = data.GetGMapUserGroup(base.RDFTriple.Subject, 0, session.Session().SessionID);
                reader2 = data.GetGMapUserGroup(base.RDFTriple.Subject, 1, session.Session().SessionID);
            }

            string googleCode, tableText;

            gmh.MapPlotPeople(base.RDFTriple.Subject, reader, reader2, out googleCode, out tableText);
            litGoogleCode.Text  = googleCode;
            litNetworkText.Text = tableText;


            if (!reader.IsClosed)
            {
                reader.Close();
            }

            if (!reader2.IsClosed)
            {
                reader2.Close();
            }
        }
Ejemplo n.º 10
0
 private void buttonSaveGoogleKey_Click(object sender, EventArgs e)
 {
     try
     {
         GoogleMapHelper.PutKeyString(textGoogleMapsKey.Text.Trim());
     }
     catch (Exception ex)
     {
         alert($"Cannot Save Key. Err={ex}");
     }
 }
Ejemplo n.º 11
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => (ViewModel as BaseChallengesViewModel).Challenge))
     {
         if ((ViewModel as BaseChallengesViewModel).Challenge != null && (ViewModel as BaseChallengesViewModel).Challenge.LocationLat != null && (ViewModel as BaseChallengesViewModel).Challenge.LocationLong != null && _map != null)
         {
             GoogleMapHelper.UpdateMapZoom(_map, ViewModel.Challenge.LocationLat.Value, ViewModel.Challenge.LocationLong.Value, ViewModel.Challenge.RadiusMeters);
         }
     }
 }
Ejemplo n.º 12
0
 public string GetMapUri(float latitude, float longitude, int zoom)
 {
     return(string.Format(
                "https://maps.googleapis.com/maps/api/staticmap?center={0}&zoom={1}&size={2}&maptype={3}&format={4}&key={5}",
                $"{latitude},{longitude}",
                zoom,
                "640x640",
                GoogleMapHelper.GetGoogleMapTypeString(GoogleMapType.Satellite),
                GoogleMapHelper.GetGoogleFormatString(GoogleImageFormat.PNG32),
                GoogleMapHelper.ApiKey));
 }
Ejemplo n.º 13
0
        public async Task <byte[]> GetMapAsync(float latitude, float longitude, int zoom, int scale, int width, int height, GoogleMapType mapType, GoogleImageFormat format, IList <TrackCoordinate> trackCoordinates)
        {
            byte[] bitmap = null;

            try
            {
                var requestUri = string.Empty;

                for (int i = _resolutionModifierStep; i <= _maxResolutionModifierStep; i++)
                {
                    if (i > _resolutionModifierStep)
                    {
                        _logger.LogTrace($"Attempting to build Track Map requestUri at resolution of {i}");
                    }
                    string pathParameter = BuildMapPath(trackCoordinates, i);

                    requestUri = string.Format(
                        "https://maps.googleapis.com/maps/api/staticmap?&scale=1center={0}&zoom={1}&size={2}&maptype={3}&format={4}&key={5}{6}",
                        $"{latitude},{longitude}",
                        zoom,
                        $"{width}x{height}",
                        GoogleMapHelper.GetGoogleMapTypeString(mapType),
                        GoogleMapHelper.GetGoogleFormatString(format),
                        GoogleMapHelper.ApiKey,
                        pathParameter);

                    if (requestUri.Length < 8192)
                    {
                        break;
                    }
                    else if (requestUri.Length > 8192 && i >= _maxResolutionModifierStep)
                    {
                        throw new InvalidOperationException($"requestUri too long: {requestUri.Length}");
                    }
                }
                _logger.LogTrace($"Google Maps requestUri: {requestUri}");

                using (WebClient wc = new WebClient())
                {
                    bitmap = await wc.DownloadDataTaskAsync(new Uri(requestUri));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Exception in GetMapAsync");
                throw;
            }

            return(bitmap);
        }
Ejemplo n.º 14
0
 public void OnMapReady(GoogleMap googleMap)
 {
     try
     {
         _map = googleMap;
         if (ViewModel.Challenge != null && ViewModel.Challenge.LocationLat != null && ViewModel.Challenge.LocationLong != null && _map != null)
         {
             GoogleMapHelper.UpdateMapZoom(_map, ViewModel.Challenge.LocationLat.Value, ViewModel.Challenge.LocationLong.Value, ViewModel.Challenge.RadiusMeters);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        public void DrawProfilesModule()
        {
            Profiles.Profile.Utilities.DataIO data = new Profiles.Profile.Utilities.DataIO();

            if (Request.QueryString["Subject"] == null)
                return;

            base.RDFTriple = new RDFTriple(Convert.ToInt64(Request.QueryString["Subject"]));

            dlGoogleMapLinks.DataSource = data.GetGoogleMapZoomLinks();
            dlGoogleMapLinks.DataBind();

            SqlDataReader reader = null;
            SqlDataReader reader2 = null;

            Profiles.Framework.Utilities.SessionManagement session = new SessionManagement();

            GoogleMapHelper gmh = new GoogleMapHelper();

            try
            {
                if (base.GetModuleParamString("MapType") == "CoAuthor")
                {

                    reader = data.GetGMapUserCoAuthors(base.RDFTriple.Subject, 0, session.Session().SessionID);
                    reader2 = data.GetGMapUserCoAuthors(base.RDFTriple.Subject, 1, session.Session().SessionID);

                }

                if (base.GetModuleParamString("MapType") == "SimilarTo")
                {
                    reader = data.GetGMapUserSimilarPeople(base.RDFTriple.Subject, false, session.Session().SessionID);
                    reader2 = data.GetGMapUserSimilarPeople(base.RDFTriple.Subject, true, session.Session().SessionID);
                }

                litGoogleCode.Text = gmh.MapPlotPeople(base.RDFTriple.Subject, reader, reader2);
            }
            finally
            {
                if (!reader.IsClosed)
                    reader.Close();

                if (!reader2.IsClosed)
                    reader2.Close();
            }
        }
Ejemplo n.º 16
0
        public static int?GetDistance(string depCountry, string depCity, string depSuburb,
                                      string destCountry, string destCity, string destSuburb)
        {
            //get from db
            using (var db = new StallEntities())
            {
                var id       = BuilId(depCountry, depCity, depSuburb, destCountry, destCity, destSuburb);
                var dbResult = GetDistance(id, db);
                if (dbResult != null)
                {
                    return(dbResult);
                }

                //call google map api
                var glResult = GoogleMapHelper.GetSuburbDistanceFromGoogleMapApi(depCountry, depCity, depSuburb, destCountry, destCity, destSuburb,
                                                                                 GreenspotConfiguration.AccessAccounts["google.map"].Secret);
                if (glResult == null)
                {
                    StallApplication.SysError($"[GOOGLE DISTANCE]failed to get distance {depCountry},{depCity},{depSuburb} to {destCountry},{destCity},{destSuburb}");
                    return(null);
                }
                else
                {
                    //save to db
                    var distance = new SuburbDistance()
                    {
                        ID = id,
                        DepartureCountryCode = depCountry,
                        DepartureCity        = depCity,
                        DepartureSuburb      = depSuburb,

                        DestinationCountryCode = destCountry,
                        DestinationCity        = destCity,
                        DestinationSuburb      = destSuburb,

                        Meters = glResult.Value
                    };

                    db.SuburbDistances.Add(distance);
                    db.SaveChanges();

                    return(glResult.Value);
                }
            }
        }
        public void GoogleMapHelperTest()
        {
            var markers = new List <GoogleMapMarkers>();

            markers.Add(new GoogleMapMarkers()
            {
                Y     = 31.3,
                X     = 120.6,
                Color = "#ff0000",
                Label = "S",
                Size  = GoogleMapMarkerSize.mid
            });

            var result = GoogleMapHelper.GetGoogleStaticMap(5, markers, size: "800x800");

            Console.WriteLine(result);
            Assert.IsTrue(result.Contains("maps.googleapis.com"));
        }
Ejemplo n.º 18
0
        public async Task <bool> OnLocationMessageReceived(object sender, LocationMessageReceivedEventArgs e)
        {
            var messageHandler  = sender as WeixinMessageHandler;
            var responseMessage = new ResponseMessageNews();

            responseMessage.FromUserName = e.ToUserName;
            responseMessage.ToUserName   = e.FromUserName;

            var markersList = new List <GoogleMapMarkers>();

            markersList.Add(new GoogleMapMarkers()
            {
                Latitude  = e.Latitude,
                Longitude = e.Longitude,
                Color     = "red",
                Label     = "S",
                Size      = GoogleMapMarkerSize.Default,
            });
            var mapSize = "480x600";
            var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
                                                             markersList, mapSize);

            responseMessage.Articles.Add(new Article()
            {
                Description = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                            e.Latitude, e.Longitude,
                                            e.Scale, e.Label),
                PicUrl = mapUrl,
                Title  = "定位地点周边地图",
                Url    = mapUrl
            });
            responseMessage.Articles.Add(new Article()
            {
                Title       = "AspNetCore.Weixin",
                Description = "AspNetCore.Weixin",
                PicUrl      = "http://wx.demo.com/logo.jpg",
                Url         = "http://wx.demo.com"
            });

            await messageHandler.WriteAsync(responseMessage);

            return(true);
        }
Ejemplo n.º 19
0
        public ResponseMessageNews GetResponseMessage(PublishmentSystemInfo publishmentSystemInfo, RequestMessageLocation requestMessage, string wxOpenID)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);

            var articleList = StoreManager.TriggerStoreItem(publishmentSystemInfo, requestMessage.Location_X.ToString(), requestMessage.Location_Y.ToString(), wxOpenID);

            var markersList = new List <Markers>();

            markersList.Add(new Markers()
            {
                X     = requestMessage.Location_X,
                Y     = requestMessage.Location_Y,
                Color = "red",
                Label = "S",
                Size  = MarkerSize.Default,
            });
            var mapSize = "480x600";
            var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
                                                             markersList, mapSize);

            responseMessage.Articles.Add(new Article()
            {
                Description =
                    $"根据您的地理位置获取的附近门店。Location_X:{requestMessage.Location_X},Location_Y:{requestMessage.Location_Y},Scale:{requestMessage.Scale},标签:{requestMessage.Label}",
                PicUrl = articleList[0].PicUrl,
                Title  = articleList[0].Title,
                Url    = articleList[0].Url
            });

            if (articleList.Count > 0)
            {
                foreach (var article in articleList)
                {
                    responseMessage.Articles.Add(article);
                }
            }

            return(responseMessage);
        }
Ejemplo n.º 20
0
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);

            var markersList = new List <Markers>();

            markersList.Add(new Markers()
            {
                X     = requestMessage.Location_X,
                Y     = requestMessage.Location_Y,
                Color = "red",
                Label = "S",
                Size  = MarkerSize.Default,
            });
            var mapSize = "480x600";
            var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
                                                             markersList, mapSize);

            responseMessage.Articles.Add(new Article()
            {
                Description = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                            requestMessage.Location_X, requestMessage.Location_Y,
                                            requestMessage.Scale, requestMessage.Label),
                PicUrl = mapUrl,
                Title  = "定位地点周边地图",
                Url    = mapUrl
            });
            responseMessage.Articles.Add(new Article()
            {
                Title       = "开发者官网",
                Description = "From Liujun",
                PicUrl      = "https://mail.qq.com/cgi-bin/viewfile?f=687B756EADCF463FE682F979C2B6000909749CF39A4711F264A28B5A1AF42AA3A89436733680D5B4B5C7E67AFB48DC4D6B4222A3414F6D1EE58B48B1F62C186B12BE9FEDED6C71E2&sid=KlxWmjnm3npQVEES",
                Url         = "http://www.fliujun.com"
            });

            return(responseMessage);
        }
Ejemplo n.º 21
0
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);

            var markersList = new List <GoogleMapMarkers>();

            markersList.Add(new GoogleMapMarkers()
            {
                X     = requestMessage.Location_X,
                Y     = requestMessage.Location_Y,
                Color = "red",
                Label = "S",
                Size  = GoogleMapMarkerSize.Default,
            });
            var mapSize = "480x600";
            var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
                                                             markersList, mapSize);

            responseMessage.Articles.Add(new Article()
            {
                Description = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                            requestMessage.Location_X, requestMessage.Location_Y,
                                            requestMessage.Scale, requestMessage.Label),
                PicUrl = mapUrl,
                Title  = "定位地点周边地图",
                Url    = mapUrl
            });
            responseMessage.Articles.Add(new Article()
            {
                Title       = "计划管理平台",
                Description = "计划管理平台",
                PicUrl      = "http://59.61.72.34:8023/Content/images/client/WPM/top_logo.png",
                Url         = "http://59.61.72.34:8023"
            });

            return(responseMessage);
        }
Ejemplo n.º 22
0
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);

            var markersList = new List <GoogleMapMarkers>();

            markersList.Add(new GoogleMapMarkers()
            {
                X     = requestMessage.Location_X,
                Y     = requestMessage.Location_Y,
                Color = "red",
                Label = "S",
                Size  = GoogleMapMarkerSize.Default,
            });
            var mapSize = "480x600";
            var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
                                                             markersList, mapSize);

            responseMessage.Articles.Add(new Article()
            {
                Description = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                            requestMessage.Location_X, requestMessage.Location_Y,
                                            requestMessage.Scale, requestMessage.Label),
                PicUrl = mapUrl,
                Title  = "定位地点周边地图",
                Url    = mapUrl
            });
            responseMessage.Articles.Add(new Article()
            {
                Title       = "微信公众平台SDK 官网链接",
                Description = "Senparc.Weixin.MK SDK地址",
                PicUrl      = "http://weixin.senparc.com/images/logo.jpg",
                Url         = "http://weixin.senparc.com"
            });

            return(responseMessage);
        }
Ejemplo n.º 23
0
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);

            #region 百度地图

            {
                var markersList = new List <BaiduMarkers>();
                markersList.Add(new BaiduMarkers()
                {
                    Longitude = requestMessage.Location_X,
                    Latitude  = requestMessage.Location_Y,
                    Color     = "red",
                    Label     = "S",
                    Size      = BaiduMarkerSize.m
                });

                var mapUrl = BaiduMapHelper.GetBaiduStaticMap(requestMessage.Location_X, requestMessage.Location_Y, 1, 6, markersList);
                responseMessage.Articles.Add(new Article()
                {
                    Description = string.Format("【来自百度地图】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                                requestMessage.Location_X, requestMessage.Location_Y,
                                                requestMessage.Scale, requestMessage.Label),
                    PicUrl = mapUrl,
                    Title  = "定位地点周边地图",
                    Url    = mapUrl
                });
            }

            #endregion

            #region GoogleMap

            {
                var markersList = new List <GoogleMapMarkers>();
                markersList.Add(new GoogleMapMarkers()
                {
                    X     = requestMessage.Location_X,
                    Y     = requestMessage.Location_Y,
                    Color = "red",
                    Label = "S",
                    Size  = GoogleMapMarkerSize.Default,
                });
                var mapSize = "480x600";
                var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
                                                                 markersList, mapSize);
                responseMessage.Articles.Add(new Article()
                {
                    Description = string.Format("【来自GoogleMap】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                                requestMessage.Location_X, requestMessage.Location_Y,
                                                requestMessage.Scale, requestMessage.Label),
                    PicUrl = mapUrl,
                    Title  = "定位地点周边地图",
                    Url    = mapUrl
                });
            }

            #endregion


            responseMessage.Articles.Add(new Article()
            {
                Title       = "微信公众平台SDK 官网链接",
                Description = "",
                PicUrl      = "",
                Url         = ""
            });

            return(responseMessage);
        }
Ejemplo n.º 24
0
        protected virtual string BuildMapPath(IList <TrackCoordinate> trackCoordinates, int resolution)
        {
            string pathParameter = String.Empty;

            if (trackCoordinates != null && trackCoordinates.Count > 0)
            {
                LapSegment         lapSegment  = null;
                IList <LapSegment> lapSegments = new List <LapSegment>();

                string throttlePathHeader = "&path=color:green|weight:2";
                string brakePathHeader    = "&path=color:red|weight:2";
                string coastPathHeader    = "&path=color:yellow|weight:2";
                string currentState       = "";

                var firsttrackCoordinate = trackCoordinates.FirstOrDefault();
                lapSegment = new LapSegment();

                if (firsttrackCoordinate.Throttle > 0 && firsttrackCoordinate.Throttle > firsttrackCoordinate.Brake)
                {
                    currentState      = "Throttle";
                    lapSegment.Header = throttlePathHeader;
                }
                else if (firsttrackCoordinate.Brake > 0 && firsttrackCoordinate.Brake > firsttrackCoordinate.Throttle)
                {
                    currentState      = "Brake";
                    lapSegment.Header = brakePathHeader;
                }
                else
                {
                    currentState      = "Coast";
                    lapSegment.Header = coastPathHeader;
                }

                foreach (TrackCoordinate trackCoordinate in trackCoordinates.Where((x, i) => i % resolution == 0))
                {
                    lapSegment.Points.Add(trackCoordinate);

                    if (trackCoordinate.Throttle > 0 && trackCoordinate.Throttle > trackCoordinate.Brake)
                    {
                        if (currentState != "Throttle")
                        {
                            lapSegment.EncodedToken = GoogleMapHelper.EncodeCoordinates(lapSegment.Points);
                            lapSegments.Add(lapSegment);
                            lapSegment = new LapSegment()
                            {
                                Header = throttlePathHeader
                            };
                            lapSegment.Points.Add(trackCoordinate);
                            currentState = "Throttle";
                        }
                    }
                    else if (trackCoordinate.Brake > 0 && trackCoordinate.Brake > trackCoordinate.Throttle)
                    {
                        if (currentState != "Brake")
                        {
                            lapSegment.EncodedToken = GoogleMapHelper.EncodeCoordinates(lapSegment.Points);
                            lapSegments.Add(lapSegment);
                            lapSegment = new LapSegment()
                            {
                                Header = brakePathHeader
                            };
                            lapSegment.Points.Add(trackCoordinate);
                            currentState = "Brake";
                        }
                    }
                    else
                    {
                        if (currentState != "Coast")
                        {
                            lapSegment.EncodedToken = GoogleMapHelper.EncodeCoordinates(lapSegment.Points);
                            lapSegments.Add(lapSegment);
                            lapSegment = new LapSegment()
                            {
                                Header = coastPathHeader
                            };
                            lapSegment.Points.Add(trackCoordinate);
                            currentState = "Coast";
                        }
                    }
                }
                // add the last segment
                lapSegment.EncodedToken = GoogleMapHelper.EncodeCoordinates(lapSegment.Points);
                lapSegments.Add(lapSegment);

                StringBuilder sb = new StringBuilder();

                foreach (LapSegment encodedLapSegment in lapSegments)
                {
                    sb.Append(encodedLapSegment.Header);
                    sb.Append("|enc:");
                    sb.Append(encodedLapSegment.EncodedToken);
                }

                pathParameter = sb.ToString();
            }

            return(pathParameter);
        }
Ejemplo n.º 25
0
        //private void OnCommentButtonClick(object sender, EventArgs e)
        //{
        //    Delegate.PostComment(AdapterPosition);
        //}

        //private void OnLikeButtonClick(object sender, EventArgs e)
        //{
        //    Delegate.PostLike(AdapterPosition);
        //}

        //private void OnReadCommentButtonClick(object sender, EventArgs e)
        //{
        //    OnShowAllCommentsButtonClicked();
        //    _readAllCommentsButton.Visibility = ViewStates.Gone;
        //}

        //private void OnLoadFriendFeedButtonClick(object sender, EventArgs e)
        //{
        //    Delegate.LoadProfileDetails(AdapterPosition, (MvxCachedImageView)sender);
        //}

        public void OnMapReady(GoogleMap googleMap)
        {
            GoogleMapHelper.UpdateMapZoom(googleMap, _latitude, _longitude, 5);
            CurrentMap = googleMap;
        }