コード例 #1
0
ファイル: ApiContainer.cs プロジェクト: drazenzadravec/nequeo
        /// <summary>
        /// Get the static image map.
        /// </summary>
        /// <param name="maps">The static map model.</param>
        /// <returns>The array of bytes containing image data.</returns>
        public byte[] GetStaticMapImage(MapsStatic maps)
        {
            string query = "";

            if (maps.DeclutterPins != null)
            {
                query += "&declutter=" + System.Uri.EscapeDataString(maps.DeclutterPins);
            }
            if (maps.Format != null)
            {
                query += "&format=" + System.Uri.EscapeDataString(maps.Format);
            }
            if (maps.MapArea != null)
            {
                query += "&mapArea=" + System.Uri.EscapeDataString(maps.MapArea);
            }
            if (maps.MapLayer != null)
            {
                query += "&mapLayer=" + System.Uri.EscapeDataString(maps.MapLayer);
            }
            if (maps.MapSize != null)
            {
                query += "&mapSize=" + System.Uri.EscapeDataString(maps.MapSize);
            }
            if (maps.PushPins != null)
            {
                foreach (MapsStatic.PushPin pushpin in maps.PushPins)
                {
                    string pushpinQuery = "";

                    if (pushpin.Location != null)
                    {
                        pushpinQuery += pushpin.Location + ";";
                    }
                    if (pushpin.IconStyle != null || pushpin.Label != null)
                    {
                        if (pushpin.IconStyle != null)
                        {
                            pushpinQuery += pushpin.IconStyle + ";";
                        }
                        else
                        {
                            pushpinQuery += ";";
                        }
                        if (pushpin.Label != null)
                        {
                            pushpinQuery += pushpin.Label + ";";
                        }
                    }
                    if (!String.IsNullOrEmpty(pushpinQuery))
                    {
                        query += "&pushpin=" + System.Uri.EscapeDataString(pushpinQuery.TrimEnd(';'));
                    }
                }
            }
            if (maps.MapMetadata != null)
            {
                query += "&mmd=" + System.Uri.EscapeDataString(maps.MapMetadata);
            }
            if (maps.HighlightEntity != null)
            {
                query += "&he=" + System.Uri.EscapeDataString(maps.HighlightEntity);
            }
            if (maps.EntityType != null)
            {
                query += "&entityType=" + System.Uri.EscapeDataString(maps.EntityType);
            }
            if (maps.Route != null)
            {
                if (maps.Route.Avoid != null)
                {
                    query += "&avoid=" + System.Uri.EscapeDataString(maps.Route.Avoid);
                }
                if (maps.Route.DistanceBeforeFirstTurn != null)
                {
                    query += "&dbft=" + System.Uri.EscapeDataString(maps.Route.DistanceBeforeFirstTurn);
                }
                if (maps.Route.DateTime != null)
                {
                    query += "&dateTime=" + System.Uri.EscapeDataString(maps.Route.DateTime);
                }
                if (maps.Route.MaxSolutions != null)
                {
                    query += "&maxSolns=" + System.Uri.EscapeDataString(maps.Route.MaxSolutions);
                }
                if (maps.Route.Optimize != null)
                {
                    query += "&optimize=" + System.Uri.EscapeDataString(maps.Route.Optimize);
                }
                if (maps.Route.TimeType != null)
                {
                    query += "&timeType=" + System.Uri.EscapeDataString(maps.Route.TimeType);
                }
                if (maps.Route.TravelMode != null)
                {
                    query += "&travelMode=" + System.Uri.EscapeDataString(maps.Route.TravelMode);
                }
                if (maps.Route.WayPoints != null)
                {
                    int wpIndex = 1;

                    foreach (MapsStaticRoute.WayPoint waypoint in maps.Route.WayPoints)
                    {
                        string waypointQuery = "";

                        if (waypoint.Location != null)
                        {
                            waypointQuery += waypoint.Location + ";";
                        }
                        if (waypoint.IconStyle != null || waypoint.Label != null)
                        {
                            if (waypoint.IconStyle != null)
                            {
                                waypointQuery += waypoint.IconStyle + ";";
                            }
                            else
                            {
                                waypointQuery += ";";
                            }
                            if (waypoint.Label != null)
                            {
                                waypointQuery += waypoint.Label + ";";
                            }
                        }
                        if (!String.IsNullOrEmpty(waypointQuery))
                        {
                            query += "&wp." + wpIndex.ToString() + "=" + System.Uri.EscapeDataString(waypointQuery.TrimEnd(';'));
                            wpIndex++;
                        }
                    }
                }
            }
            if ((_apiKey != null))
            {
                query += "&key=" + _apiKey;
            }

            // Process the request.
            return(ProcessRequest(query,
                                  (maps.ImagerySet != null ? System.Uri.EscapeDataString(maps.ImagerySet) : null),
                                  (maps.Query != null ? System.Uri.EscapeDataString(maps.Query) : null),
                                  (maps.CenterPoint != null ? System.Uri.EscapeDataString(maps.CenterPoint) : null),
                                  (maps.ZoomLevel != null ? System.Uri.EscapeDataString(maps.ZoomLevel) : null)));
        }
コード例 #2
0
 /// <summary>
 /// Get the static image map.
 /// </summary>
 /// <param name="maps">The static map model.</param>
 /// <returns>The array of bytes containing image data.</returns>
 public byte[] GetStaticMapImage(MapsStatic maps)
 {
     Initialise();
     return(_container.GetStaticMapImage(maps));
 }