Beispiel #1
0
        internal RouteSearchRequest(MapService service, Geocoordinates from, Geocoordinates to) : this(service, ServiceRequestType.SearchRoute)
        {
            _to   = to;
            _from = from;
            startExecutionAction = new Action(() =>
            {
                int requestID;
                errMessage = $"Failed to get route list for given origin {_from} and destination {_to}";
                if (_waypoints?.Count == 0)
                {
                    _type     = ServiceRequestType.SearchRoute;
                    errorCode = _service.handle.SearchRoute(_from.handle, _to.handle, _service.Preferences.handle, _routeCallback, IntPtr.Zero, out requestID);
                    if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled)
                    {
                        _requestTask?.TrySetException(errorCode.GetException(errMessage));
                    }
                }
                else
                {
                    _type = ServiceRequestType.SearchRouteWithWaypoints;

                    var waypoints = GetCoordinateListForWaypoints();
                    errorCode     = _service.handle.SearchRouteWaypoints(waypoints, waypoints.Length, _service.Preferences.handle, _routeCallback, IntPtr.Zero, out requestID);
                    if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled)
                    {
                        _requestTask?.TrySetException(errorCode.GetException(errMessage));
                    }
                }
                _requestID = requestID;
            });
        }
Beispiel #2
0
 private RouteSearchRequest(MapService service, ServiceRequestType type) : base(service, type)
 {
     // The Maps Service invokes this callback while iterating through the set of obtained Routes.
     _routeCallback = (result, id, index, total, route, userData) =>
     {
         errorCode = result;
         if (result.IsSuccess())
         {
             // The parameter route must be released using maps_route_destroy().
             var routeHandle = new Interop.RouteHandle(route, needToRelease: true);
             _routeList.Add(new Route(routeHandle));
             if (_routeList.Count == total)
             {
                 _requestTask?.TrySetResult(_routeList);
             }
             return(true);
         }
         else
         {
             // If search is failed, the value of total is 0 and route is NULL.
             _requestTask?.TrySetException(errorCode.GetException(errMessage));
             return(false);
         }
     };
 }
        internal ReverseGeocodeRequest(MapService service, double latitude, double longitute) : base(service, ServiceRequestType.ReverseGeocode)
        {
            // The Maps Service invokes this callback when the address is obtained from the specified coordinates.
            _geocodeCallback = (result, id, index, total, address, userData) =>
            {
                errorCode = result;
                if (result.IsSuccess())
                {
                    // The parameter address must be released using maps_address_destroy().
                    var addressHandle = new Interop.AddressHandle(address, needToRelease: true);
                    _addressList.Add(new PlaceAddress(addressHandle));
                    if (_addressList.Count == total)
                    {
                        _requestTask?.TrySetResult(_addressList);
                    }
                }
                else
                {
                    // If search is failed, the value of total is 0 and address is NULL
                    _requestTask?.TrySetException(errorCode.GetException(errMessage));
                }
            };

            startExecutionAction = new Action(() =>
            {
                int requestID;
                errMessage = $"Failed to get address for given coordinates: {latitude}:{longitute}";
                errorCode  = _service.handle.ReverseGeocode(latitude, longitute, _service.Preferences.handle, _geocodeCallback, IntPtr.Zero, out requestID);
                if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled)
                {
                    _requestTask?.TrySetException(errorCode.GetException(errMessage));
                }
                _requestID = requestID;
            });
        }
Beispiel #4
0
 private GeocodeRequest(MapService service, ServiceRequestType type) : base(service, type)
 {
     // The Maps Service invokes this callback while iterating through the list of obtained coordinates of the specified place.
     _geocodeCallback = (result, id, index, total, coordinates, userData) =>
     {
         errorCode = result;
         if (result.IsSuccess())
         {
             // The parameter coordinates must be released using maps_coordinates_destroy()
             var coordinatesHandle = new Interop.CoordinatesHandle(coordinates, needToRelease: true);
             _coordinateList.Add(new Geocoordinates(coordinatesHandle));
             if (_coordinateList.Count == total)
             {
                 _requestTask?.TrySetResult(_coordinateList);
             }
             return(true);
         }
         else
         {
             // If the search fails, the value of total is 0 and coordinates is NULL.
             _requestTask?.TrySetException(result.GetException(errMessage));
             return(false);
         }
     };
 }
Beispiel #5
0
        /// <summary>
        /// Creates a view and links it to the instance of a map service.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="parent">An instance of <see cref="EvasObject"/> object for which a map view will be drawn.</param>
        /// <param name="service">An instance of <see cref="MapService"/> object.</param>
        /// <privilege>http://tizen.org/privilege/mapservice</privilege>
        /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
        /// <exception cref="System.ArgumentException">Thrown when parameters are invalid.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when a native operation failed to allocate memory, and connect to the service.</exception>
        public MapView(EvasObject parent, MapService service) : base(parent)
        {
            handle = new Interop.ViewHandle(service.handle, this);
            service.handle.HasOwnership = false;
            Log.Info(string.Format("MapView is created"));

            _service = service;
            this.Resize(1, 1);

            // We need to keep Gesture Tap event enabled for object event to work
            handle.SetGestureEnabled(Interop.ViewGesture.Click, true);
            SetObjectEventCallback();
        }
Beispiel #6
0
 internal PlaceSearchRequest(MapService service, string address, Area boundary) : this(service, ServiceRequestType.SearchPlaceByAddress)
 {
     startExecutionAction = new Action(() =>
     {
         int requestID;
         errMessage = $"Failed to get coordinates for address {address} in given boundary";
         errorCode  = _service.handle.SearchPlaceByAddress(address, boundary.handle, _service.PlaceSearchFilter.handle, _service.Preferences.handle, _placeCallback, IntPtr.Zero, out requestID);
         if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled)
         {
             _requestTask?.TrySetException(errorCode.GetException(errMessage));
         }
         _requestID = requestID;
     });
 }
Beispiel #7
0
 internal PlaceSearchRequest(MapService service, Geocoordinates position, int distance) : this(service, ServiceRequestType.SearchPlace)
 {
     startExecutionAction = new Action(() =>
     {
         int requestID;
         errMessage = $"Failed to get place list for given co-ordinate {position} and distance {distance}";
         errorCode  = _service.handle.SearchPlace(position.handle, distance, _service.PlaceSearchFilter.handle, _service.Preferences.handle, _placeCallback, IntPtr.Zero, out requestID);
         if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled)
         {
             _requestTask?.TrySetException(errorCode.GetException(errMessage));
         }
         _requestID = requestID;
     });
 }
Beispiel #8
0
 internal GeocodeRequest(MapService service, PlaceAddress address) : this(service, ServiceRequestType.GeocodeByStructuredAddress)
 {
     startExecutionAction = new Action(() =>
     {
         int requestID;
         errMessage = $"Failed to get coordinates for given address {address}";
         errorCode  = _service.handle.GeocodeByStructuredAddress(address.handle, _service.Preferences.handle, _geocodeCallback, IntPtr.Zero, out requestID);
         if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled)
         {
             _requestTask?.TrySetException(errorCode.GetException(errMessage));
         }
         _requestID = requestID;
     });
 }
Beispiel #9
0
        internal MultiReverseGeocodeRequest(MapService service, IEnumerable <Geocoordinates> coordinates) : base(service, ServiceRequestType.ReverseGeocode)
        {
            // The Maps Service invokes this callback once when gets the response from map service provider
            // The value of total is same with requested coordinates list size. Even though one of address is not provided valid address handle is retrieved.
            _geocodeCallback = (result, id, total, handle, userData) =>
            {
                errorCode = result;
                if (result.IsSuccess())
                {
                    var addressListHandle = new Interop.AddressListHandle(handle, needToRelease: true);
                    var addressList       = new PlaceAddressList(addressListHandle);
                    _addressesList = addressList.Addresses as List <PlaceAddress>;
                    _requestTask?.TrySetResult(_addressesList);
                    return(true);
                }
                else
                {
                    _requestTask?.TrySetException(errorCode.GetException(errMessage));
                    return(false);
                }
            };

            var coordinateList = new GeocoordinatesList(coordinates);

            startExecutionAction = new Action(() =>
            {
                int requestID;
                errMessage = "Failed to get address list for given co-ordinate list";
                errorCode  = _service.handle.MultiReverseGeocode(coordinateList.handle, _service.Preferences.handle, _geocodeCallback, IntPtr.Zero, out requestID);
                if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled)
                {
                    _requestTask?.TrySetException(errorCode.GetException(errMessage));
                }
                _requestID = requestID;
            });
        }
Beispiel #10
0
 /// <summary>
 /// Creates a map service request.
 /// </summary>
 /// <param name="service">Map service object.</param>
 /// <param name="type">Request type.</param>
 internal MapServiceRequest(MapService service, ServiceRequestType type)
 {
     _service = service;
     _type    = type;
 }