Exemplo n.º 1
0
        public string GetMapsUri(string url, ref string refText)
        {
            if (!Configs.Instance.IsPreviewFoursquare)
            {
                return(null);
            }

            var urlId = Regex.Replace(url, "https?://(4sq|foursquare)\\.com/", string.Empty);

            if (_checkInUrlsVenueCollection.ContainsKey(urlId))
            {
                refText = _checkInUrlsVenueCollection[urlId].LocateInfo;
                return((new Google()).CreateGoogleStaticMapsUri(_checkInUrlsVenueCollection[urlId]));
            }

            var venueId = GetVenueId(url);

            if (string.IsNullOrEmpty(venueId))
            {
                return(null);
            }

            var curVenue = GetVenueInfo(venueId);

            if (curVenue == null)
            {
                return(null);
            }

            var curLocation = new Google.GlobalLocation
            {
                Latitude   = curVenue.Location.Latitude,
                Longitude  = curVenue.Location.Longitude,
                LocateInfo = CreateVenueInfoText(curVenue)
            };

            // 例外発生の場合があるため
            if (!_checkInUrlsVenueCollection.ContainsKey(urlId))
            {
                _checkInUrlsVenueCollection.Add(urlId, curLocation);
            }

            refText = curLocation.LocateInfo;
            return(new Google().CreateGoogleStaticMapsUri(curLocation));
        }
Exemplo n.º 2
0
        public string GetMapsUri(string url, ref string refText)
        {
            if (!Configs.Instance.IsPreviewFoursquare)
            {
                return null;
            }

            var urlId = Regex.Replace(url, "https?://(4sq|foursquare)\\.com/", string.Empty);

            if (_checkInUrlsVenueCollection.ContainsKey(urlId))
            {
                refText = _checkInUrlsVenueCollection[urlId].LocateInfo;
                return (new Google()).CreateGoogleStaticMapsUri(_checkInUrlsVenueCollection[urlId]);
            }

            var venueId = GetVenueId(url);
            if (string.IsNullOrEmpty(venueId))
            {
                return null;
            }

            var curVenue = GetVenueInfo(venueId);
            if (curVenue == null)
            {
                return null;
            }

            var curLocation = new Google.GlobalLocation
            {
                Latitude = curVenue.Location.Latitude,
                Longitude = curVenue.Location.Longitude,
                LocateInfo = CreateVenueInfoText(curVenue)
            };

            // 例外発生の場合があるため
            if (!_checkInUrlsVenueCollection.ContainsKey(urlId))
            {
                _checkInUrlsVenueCollection.Add(urlId, curLocation);
            }

            refText = curLocation.LocateInfo;
            return new Google().CreateGoogleStaticMapsUri(curLocation);
        }