Example #1
0
 void Start()
 {
     _map = GameObject.Find("Map").GetComponent <MapRenderer>();
     Debug.Assert(_map != null);
     _mapPin = GetComponent <MapPin>();
     Debug.Assert(_mapPin != null);
 }
Example #2
0
        public void OnModuleClientLeave()
        {
            NWPlayer oPC = (_.GetExitingObject());

            if (!oPC.IsPlayer)
            {
                return;
            }

            foreach (var pin in _data.Where <PCMapPin>(x => x.PlayerID == oPC.GlobalID))
            {
                _data.SubmitDataChange(pin, DatabaseActionType.Delete);
            }

            for (int x = 0; x < GetNumberOfMapPins(oPC); x++)
            {
                MapPin mapPin = GetMapPin(oPC, x);

                if (string.IsNullOrWhiteSpace(mapPin.Text))
                {
                    continue;
                }

                PCMapPin entity = new PCMapPin
                {
                    AreaTag   = mapPin.Area.Tag,
                    NoteText  = mapPin.Text,
                    PlayerID  = oPC.GlobalID,
                    PositionX = mapPin.PositionX,
                    PositionY = mapPin.PositionY
                };

                _data.SubmitDataChange(entity, DatabaseActionType.Insert);
            }
        }
Example #3
0
        async private void ExecuteCommandGetCoordinatePin(MapPin mapPin)
        {
            var param = new NavigationParameters();

            param.Add("PinCoordinate", mapPin);
            await _navigationService.NavigateAsync(nameof(MapPage), param);
        }
Example #4
0
        private void savePins()
        {
            for (int i = 0; i < mMapPinsList.Count; i++)
            {
                if (!savedPinsList.Contains(mMapPinsList[i]))
                {
                    unSavedPinsList.Add(mMapPinsList[i]);
                }
            }

            foreach (map_pins MapPin in unSavedPinsList)
            {
                String unsavedPins = MapPin.toString();

                //This will save some text to a file in the same folder as your project exe file
                if (File.Exists(fileName))
                {
                    using (StreamWriter sw = new StreamWriter(fileName, true))
                        sw.WriteLine(unsavedPins);
                }
                else
                {
                    File.Create(fileName);
                    using (StreamWriter sw = new StreamWriter(fileName))
                        sw.WriteLine(unsavedPins);
                }
            }
        }
Example #5
0
        async private void ExecuteNavigateCommandAddNewPin()
        {
            var coord = new MapPin()
            {
                Latitude    = Latitude,
                Longitude   = Longitude,
                Description = Description
            };

            if (!string.IsNullOrEmpty(Latitude) || !string.IsNullOrEmpty(Longitude) || !string.IsNullOrEmpty(Description))
            {
                if (!ChekCoordinate(Latitude, Longitude))
                {
                    _mapPinsService.SavePin(coord);
                    await _userDialogs.AlertAsync("Coordinate is added", null, "OK");

                    Latitude    = string.Empty;
                    Longitude   = string.Empty;
                    Description = string.Empty;
                }
                else
                {
                    await _userDialogs.AlertAsync("Coordinate alredy exist", "Warning", "OK");
                }
            }
            else
            {
                await _userDialogs.AlertAsync("Fields cannot be Empty", "ERROR", "OK");
            }
        }
Example #6
0
        private async void MapTapped(
            object sender,
            TappedRoutedEventArgs e)
        {
            Grid grid = e.OriginalSource as Grid;

            if (grid == null && e.OriginalSource != null)
            {
                grid = (e.OriginalSource as FrameworkElement).Parent as Grid;
            }
            if ((grid == null || grid.Name != "MapPinRoot") && _focusedMapPin != null)
            {
                if (!_focusedMapPin.Marked)
                {
                    MapView.Children.Remove(_focusedMapPin);
                }
                else
                {
                    _focusedMapPin.UnFocus();
                }
                _focusedMapPin = null;
                DefaultViewModel["FolderSelected"] = false;
            }
            else if (_focusedMapPin != null)
            {
                _mapLocationFolderAccess.MapLocationId = _focusedMapPin.ID;
                _mapLocationFolders = await _mapLocationFolderAccess.GetSources(DataSourceType.Sqlite);

                DefaultViewModel["MapLocationFolders"] = _mapLocationFolders;
            }
            DefaultViewModel["Focused"]    = _focusedMapPin != null;
            DefaultViewModel["Linkable"]   = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked;
            DefaultViewModel["Markable"]   = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"];
            DefaultViewModel["UnMarkable"] = (bool)DefaultViewModel["Linkable"];
        }
Example #7
0
        public static void SetMapPin(NWPlayer oPC, string text, float positionX, float positionY, NWArea area, string tag)
        {
            int numberOfMapPins = GetNumberOfMapPins(oPC);
            int storeAtIndex    = -1;

            for (int index = 0; index < numberOfMapPins; index++)
            {
                MapPin mapPin = GetMapPin(oPC, index);
                if (string.IsNullOrWhiteSpace(mapPin.Text))
                {
                    storeAtIndex = index;
                    break;
                }
            }

            if (storeAtIndex == -1)
            {
                numberOfMapPins++;
                storeAtIndex = numberOfMapPins - 1;
            }

            storeAtIndex++;

            oPC.SetLocalString("NW_MAP_PIN_NTRY_" + storeAtIndex, text);
            oPC.SetLocalFloat("NW_MAP_PIN_XPOS_" + storeAtIndex, positionX);
            oPC.SetLocalFloat("NW_MAP_PIN_YPOS_" + storeAtIndex, positionY);
            oPC.SetLocalObject("NW_MAP_PIN_AREA_" + storeAtIndex, area.Object);
            oPC.SetLocalInt("NW_TOTAL_MAP_PINS", numberOfMapPins);

            if (tag != null)
            {
                oPC.SetLocalString("CUSTOM_NW_MAP_PIN_TAG_" + storeAtIndex, tag);
            }
        }
Example #8
0
 private void UpdatePinColor(MapPin pin, MKPinAnnotationView nativeView)
 {
     if (nativeView != null)
     {
         nativeView.PinTintColor = pin.Color.ToUIColor();
     }
 }
Example #9
0
 void Start()
 {
     _map = GameObject.FindWithTag("Map").GetComponent <MapRenderer>();
     Debug.Assert(_map != null);
     Debug.Log("LoCATOn" + _map.ZoomLevel.ToString());
     _mapPin = GetComponent <MapPin>();
     Debug.Assert(_mapPin != null);
 }
Example #10
0
        public static void DeleteMapPin(NWPlayer oPC, string pinTag)
        {
            MapPin mapPin = GetMapPin(oPC, pinTag);

            if (mapPin != null)
            {
                DeleteMapPin(oPC, mapPin.Index);
            }
        }
Example #11
0
        private async void MapPinElementMapPinTapped(object sender,
                                                     MapPinTappedEventArgs e)
        {
            MapPin mapPinElement = (MapPin)sender;

            if (mapPinElement.Focused)
            {
                if (e.Marked)
                {
                    await _mapLocationAccess.Add(
                        DataSourceType.Sqlite,
                        new MapLocationModel
                    {
                        ID          = Guid.NewGuid(),
                        Name        = mapPinElement.Name,
                        Description = mapPinElement.Description,
                        Latitude    = mapPinElement.Latitude.ToString(),
                        Longitude   = mapPinElement.Longitude.ToString(),
                        MapId       = _map.ID
                    });

                    MapLocationModel addedLocation = _mapLocations.FirstOrDefault(location =>
                                                                                  location.Latitude == mapPinElement.Latitude.ToString() &&
                                                                                  location.Longitude == location.Longitude);
                    if (addedLocation != null)
                    {
                        mapPinElement.ID = addedLocation.ID;
                    }

                    _mapPins.Add(mapPinElement);
                }
                else
                {
                    MapLocationModel deleteLocation = _mapLocations.FirstOrDefault(location =>
                                                                                   location.ID.Equals(mapPinElement.ID));
                    if (deleteLocation != null)
                    {
                        await _mapLocationAccess.Remove(DataSourceType.Sqlite, deleteLocation);
                    }

                    _mapPins.Remove(mapPinElement);
                }
            }

            _lastFocusedMapPin = _focusedMapPin;
            _focusedMapPin     = mapPinElement;

            if (_lastFocusedMapPin != null)
            {
                _lastFocusedMapPin.UnFocus();
            }

            if (!_focusedMapPin.Focused)
            {
                _focusedMapPin.Focus();
            }
        }
Example #12
0
        private void OsmProvider_InitializationComplete(object sender, EventArgs e)
        {
            MapPin element = new MapPin(new PointG(34.0140562, -118.2880489));

            element.Text      = "Los Angeles";
            element.BackColor = Color.Red;

            this.radMap1.Layers["PinsLayer"].Add(element);
            this.radMap1.BringIntoView(element.Location, 10);
        }
Example #13
0
 /**
  * Removes a pushpin from the map.
  */
 public override void RemoveChild(IWidget child)
 {
     if (child is MapPin)
     {
         MoSync.Util.RunActionOnMainThreadSync(() =>
         {
             MapPin pin = (MapPin)child;
             mBingMap.Children.Remove(pin.Pushpin);
         });
     }
 }
Example #14
0
 protected virtual void OnPinPropertyChanged(MapPin pin, Marker marker, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == MapPin.ColorProperty.PropertyName)
     {
         marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(pin.Color.ToAndroidMarkerHue()));
     }
     else if (e.PropertyName == MapPin.PositionProperty.PropertyName)
     {
         marker.Position = pin.Position.ToLatLng();
     }
 }
Example #15
0
 private void AddMarker(MapPin pin)
 {
     using (var op = new MarkerOptions())
     {
         op.SetTitle(pin.Label);
         op.SetPosition(pin.Position.ToLatLng());
         op.SetIcon(BitmapDescriptorFactory.DefaultMarker(pin.Color.ToAndroidMarkerHue()));
         var marker = NativeMap.AddMarker(op);
         pin.Id = marker.Id;
         Markers.Add(pin, marker);
     }
 }
 public int SavePin(MapPin pin)
 {
     if (pin.Id != 0)
     {
         _repository.UpdateItem(pin);
         return(pin.Id);
     }
     else
     {
         return(_repository.InsertItem(pin));
     }
 }
Example #17
0
        public MKPointAnnotation AddNativePin(MapPin pin)
        {
            var nativePin = new MKPointAnnotation
            {
                Title      = pin.Label,
                Coordinate = pin.Position.ToCoordinate2D()
            };

            _dictionary.Pins.AddOrUpdate(pin, nativePin);
            NativeMap.AddAnnotation(nativePin);
            return(nativePin);
        }
Example #18
0
        public override void OnNavigatedTo(NavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            if (parameters.Count == 0)
            {
                return;
            }

            var newMapPin = parameters["AddedMapPin"] as MapPin;

            AddedMapPin = newMapPin;
        }
Example #19
0
        private void RemoveMarker(MapPin pin)
        {
            if (Markers.ContainsKey(pin) == false)
            {
                return;
            }

            var markerToRemove = Markers[pin];

            markerToRemove.Remove();
            markerToRemove.Dispose();
            UnbindPin(pin);
            Markers.Remove(pin);
        }
Example #20
0
 /**
  * Adds a pushpin on the map.
  */
 public override void AddChild(IWidget child)
 {
     if (child is MapPin)
     {
         MoSync.Util.RunActionOnMainThreadSync(() =>
         {
             MapPin pin = (MapPin)child;
             if (!mBingMap.Children.Contains(pin.Pushpin))
             {
                 mBingMap.Children.Add(pin.Pushpin);
             }
         });
     }
 }
Example #21
0
 public void OnPinPropertyChanged(MapPin pin, MKPointAnnotation nativePin, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == MapPin.ColorProperty.PropertyName)
     {
         // Update pin's color
         var nativeView = NativeMap.ViewForAnnotation(nativePin) as MKPinAnnotationView;
         UpdatePinColor(pin, nativeView);
     }
     else if (e.PropertyName == MapPin.PositionProperty.PropertyName)
     {
         // Update pin's position
         nativePin.SetCoordinate(pin.Position.ToCoordinate2D());
     }
 }
Example #22
0
        private void MapMain_MapRightTapped(MapControl sender, MapRightTappedEventArgs args)
        {
            GeocodingLocation TapLocation = new GeocodingLocation(args.Location);

            MapPin newPin = new MapPin();

            newPin.DataContext = TapLocation;

            MapMain.Children.Add(newPin);
            MapControl.SetLocation(newPin, args.Location);
            MapControl.SetNormalizedAnchorPoint(newPin, new Point(0.5, 1));

            NavigationManager.Current.ShowLocation(TapLocation);
        }
Example #23
0
    public override void Awake()
    {
        base.Awake();
        _mapPin = GetComponent<MapPin>();

        _aliveCount = 0;
        if (Randomize)
        {
            foreach (var s in Spawners)
            {
                s.transform.localPosition = Random.insideUnitSphere * Radius;
                s.OnSpawn += OnSpawnShip;
            }
        }
    }
Example #24
0
    public void AddPin(MapPin pin)
    {
        if (_pins == null)
            _pins = new List<MapPin>();

        pin.ActiveInstance = CreatePin(pin.ActivePin);
        if (pin.ActiveInstance.GetComponentInChildren<Billboard>())
            pin.ActiveInstance.GetComponentInChildren<Billboard>().UseCamera = _mapCamera;

        pin.InactiveInstance = CreatePin(pin.InactivePin);
        if (pin.InactiveInstance.GetComponentInChildren<Billboard>())
            pin.InactiveInstance.GetComponentInChildren<Billboard>().UseCamera = _mapCamera;

        _pins.Add(pin);
    }
Example #25
0
        public static void DeleteMapPin(NWPlayer oPC, int index)
        {
            int numberOfPins = GetNumberOfMapPins(oPC);

            if (index > numberOfPins - 1)
            {
                return;
            }
            MapPin mapPin = GetMapPin(oPC, index);

            if (mapPin != null)
            {
                oPC.SetLocalString("NW_MAP_PIN_NTRY_" + index, string.Empty);
            }
        }
Example #26
0
    // For each panorama in the given list, create an associated MapPin on the map.
    // This is called by the AppCoordinator when the app launches.

    public void CreatePins(Panorama[] panoramas)
    {
        pins = new List <MapPin>(panoramas.Length);

        for (int i = 0; i < panoramas.Length; i++)
        {
            GameObject g = Instantiate(mapPinPrefab);
            g.transform.SetParent(mapPinHolder);
            g.transform.localPosition = panoramas[i].position;

            MapPin p = g.GetComponent <MapPin>();
            p.Initialize(this, panoramas[i]);
            pins.Add(p);
        }
    }
Example #27
0
        public static MapPin GetMapPin(NWPlayer oPC, int index)
        {
            index++;
            MapPin mapPin = new MapPin
            {
                Text      = oPC.GetLocalString("NW_MAP_PIN_NTRY_" + index),
                PositionX = oPC.GetLocalFloat("NW_MAP_PIN_XPOS_" + index),
                PositionY = oPC.GetLocalFloat("NW_MAP_PIN_YPOS_" + index),
                Area      = (oPC.GetLocalObject("NW_MAP_PIN_AREA_" + index)),
                Tag       = oPC.GetLocalString("CUSTOM_NW_MAP_PIN_TAG_" + index),
                Player    = oPC,
                Index     = index
            };

            return(mapPin);
        }
        /// <summary>
        /// Save pin in local DB
        /// </summary>
        private async void AddPin()
        {
            var newMapPin = new MapPin
            {
                Address     = Address,
                Name        = Name,
                Description = Description,
                Raiting     = SelectedRaiting
            };

            _realm.Write(() => _realm.Add(newMapPin));

            NavigationParameters parameters = new NavigationParameters();

            parameters.Add("AddedMapPin", newMapPin);

            await _navigationService.GoBackAsync(parameters);
        }
Example #29
0
        private void MapViewViewChanged(object sender,
                                        ViewChangedEventArgs e)
        {
            foreach (MapPin mapPin in _mapPins)
            {
                if (DataSource.FocusedLocationId != null && DataSource.FocusedLocationId.Value.Equals(mapPin.ID))
                {
                    _focusedMapPin = mapPin;
                    UpdateMapFolderList(DataSource.FocusedLocationId.Value);
                    //DataSource.SelectedStorageFolders = new List<StorageFolder>();

                    mapPin.Focus();
                    DefaultViewModel["Focused"]  = true;
                    DataSource.FocusedLocationId = null;
                }
                mapPin.Mark();
            }

            MapView.ViewChanged -= MapViewViewChanged;
        }
Example #30
0
        //Shows on map user specified cache
        private void ShowOnMap()
        {
            string code;

            Console.WriteLine("Give GC code which show on map");
            code = Console.ReadLine();
            int id = myReader.GetCacheID(code.ToUpper());

            if (id != -1)
            {
                Geocache geocache = myReader.GetCache(id);

                MapPin mapPin = new MapPin(geocache as ILocate);
                mapPin.ShowOnMap(geocache.GC_Code);
            }
            else
            {
                Console.WriteLine("Not found \"{0}\"", code);
            }
        }
Example #31
0
        private void SearchPaneQuerySubmitted(
            SearchPane sender,
            SearchPaneQuerySubmittedEventArgs args)
        {
            GeocodeLocation geoCodeLocation = _searchResponse.LocationData
                                              .FirstOrDefault(locationData => locationData.Address.FormattedAddress == args.QueryText) ??
                                              _searchResponse.LocationData.FirstOrDefault();

            _lastFocusedMapPin = _focusedMapPin;

            if (geoCodeLocation != null)
            {
                MapPin existedMapPin = _mapPins.FirstOrDefault(mapPin =>
                                                               mapPin.Latitude == geoCodeLocation.Location.Latitude.ToString() &&
                                                               mapPin.Longitude == geoCodeLocation.Location.Longitude.ToString());
                if (existedMapPin == null)
                {
                    MapPin mapPinElement = new MapPin(string.Empty, string.Empty,
                                                      geoCodeLocation.Location.Latitude.ToString(),
                                                      geoCodeLocation.Location.Longitude.ToString());

                    mapPinElement.MapPinTapped += MapPinElementMapPinTapped;
                    MapView.Children.Add(mapPinElement);
                    MapLayer.SetPosition(mapPinElement, geoCodeLocation.Location);
                    MapView.SetView(geoCodeLocation.Location, 15.0f);
                    _focusedMapPin = mapPinElement;
                }
                else
                {
                    Location location = new Location(double.Parse(existedMapPin.Latitude), double.Parse(existedMapPin.Longitude));
                    MapView.SetView(location, 15.0f);
                    existedMapPin.Focus();
                    _focusedMapPin = existedMapPin;
                }
                DefaultViewModel["Focused"] = true;
            }
            DefaultViewModel["Linkable"]   = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked;
            DefaultViewModel["Markable"]   = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"];
            DefaultViewModel["UnMarkable"] = (bool)DefaultViewModel["Linkable"];
        }
Example #32
0
        public void removeLocationPins(MapPin mapPin)
        {
            if (!Map.activeSelf)
            {
                ListOfDeactivatedMapPins.Add(mapPin);
                Debug.Log("Map not active for Pin Removal Count is: " + ListOfDeactivatedMapPins.Count);
            }
            else
            {
                mapPinLayer.MapPins.Remove(mapPin);
            }


            // foreach (Transform transform in transform.GetChild(1))
            // {
            //     if (transform.gameObject == gameObject)
            //     {
            //         Debug.Log("Removed MapPin "+transform.gameObject);
            //         break;
            //     }
            // }
        }
Example #33
0
        private void SetLocations(ObservableCollection<MapLocationModel> locations)
        {

            foreach (MapLocationModel mapLocation in locations)
            {
                MapPin mapPinElement = new MapPin(mapLocation.Name,
                    mapLocation.Description,
                    mapLocation.Latitude.ToString(),
                    mapLocation.Longitude.ToString()) { ID = mapLocation.ID };

                mapPinElement.MapPinTapped += MapPinElementMapPinTapped;

                MapView.Children.Add(mapPinElement);
                Location location = new Location(double.Parse(mapLocation.Latitude), double.Parse(mapLocation.Longitude));
                MapLayer.SetPosition(mapPinElement, location);
                mapPinElement.Mark();
                _mapPins.Add(mapPinElement);
            }

            MapView.ViewChanged += MapViewViewChanged;

        }
Example #34
0
 public void RemovePin(MapPin pin)
 {
     _pins.Remove(pin);
     if (pin.ActiveInstance != null)
         Destroy(pin.ActiveInstance);
 }
Example #35
0
 public override void Awake()
 {
     base.Awake();
     _mapPin = GetComponent<MapPin>();
 }
Example #36
0
 private async void MapTapped(
     object sender,
     TappedRoutedEventArgs e)
 {
     Grid grid = e.OriginalSource as Grid;
     if (grid == null && e.OriginalSource != null)
         grid = (e.OriginalSource as FrameworkElement).Parent as Grid;
     if ((grid == null || grid.Name != "MapPinRoot") && _focusedMapPin != null)
     {
         if (!_focusedMapPin.Marked)
             MapView.Children.Remove(_focusedMapPin);
         else
             _focusedMapPin.UnFocus();
         _focusedMapPin = null;
         DefaultViewModel["FolderSelected"] = false;
     }
     else if (_focusedMapPin != null)
     {
         _mapLocationFolderAccess.MapLocationId = _focusedMapPin.ID;
         _mapLocationFolders = await _mapLocationFolderAccess.GetSources(DataSourceType.Sqlite);
         DefaultViewModel["MapLocationFolders"] = _mapLocationFolders;
     }
     DefaultViewModel["Focused"] = _focusedMapPin != null;
     DefaultViewModel["Linkable"] = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked;
     DefaultViewModel["Markable"] = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"];
     DefaultViewModel["UnMarkable"] = (bool)DefaultViewModel["Linkable"];
 }
Example #37
0
        private void SearchPaneQuerySubmitted(
            SearchPane sender,
            SearchPaneQuerySubmittedEventArgs args)
        {
            GeocodeLocation geoCodeLocation = _searchResponse.LocationData
                .FirstOrDefault(locationData => locationData.Address.FormattedAddress == args.QueryText) ??
                _searchResponse.LocationData.FirstOrDefault();

            _lastFocusedMapPin = _focusedMapPin;

            if (geoCodeLocation != null)
            {
                MapPin existedMapPin = _mapPins.FirstOrDefault(mapPin =>
                    mapPin.Latitude == geoCodeLocation.Location.Latitude.ToString()
                    && mapPin.Longitude == geoCodeLocation.Location.Longitude.ToString());
                if (existedMapPin == null)
                {
                    MapPin mapPinElement = new MapPin(string.Empty, string.Empty,
                        geoCodeLocation.Location.Latitude.ToString(),
                        geoCodeLocation.Location.Longitude.ToString());

                    mapPinElement.MapPinTapped += MapPinElementMapPinTapped;
                    MapView.Children.Add(mapPinElement);
                    MapLayer.SetPosition(mapPinElement, geoCodeLocation.Location);
                    MapView.SetView(geoCodeLocation.Location, 15.0f);
                    _focusedMapPin = mapPinElement;
                }
                else
                {
                    Location location = new Location(double.Parse(existedMapPin.Latitude), double.Parse(existedMapPin.Longitude));
                    MapView.SetView(location, 15.0f);
                    existedMapPin.Focus();
                    _focusedMapPin = existedMapPin;
                }
                DefaultViewModel["Focused"] = true;
            }
            DefaultViewModel["Linkable"] = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked;
            DefaultViewModel["Markable"] = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"];
            DefaultViewModel["UnMarkable"] = (bool)DefaultViewModel["Linkable"];
        }
Example #38
0
        private async void MapPinElementMapPinTapped(object sender,
            MapPinTappedEventArgs e)
        {
            MapPin mapPinElement = (MapPin)sender;

            if (mapPinElement.Focused)
            {
                if (e.Marked)
                {
                    await _mapLocationAccess.Add(
                        DataSourceType.Sqlite,
                        new MapLocationModel
                    {
                        ID = Guid.NewGuid(),
                        Name = mapPinElement.Name,
                        Description = mapPinElement.Description,
                        Latitude = mapPinElement.Latitude.ToString(),
                        Longitude = mapPinElement.Longitude.ToString(),
                        MapId = _map.ID
                    });

                    MapLocationModel addedLocation = _mapLocations.FirstOrDefault(location =>
                        location.Latitude == mapPinElement.Latitude.ToString() &&
                        location.Longitude == location.Longitude);
                    if (addedLocation != null)
                        mapPinElement.ID = addedLocation.ID;

                    _mapPins.Add(mapPinElement);
                }
                else
                {
                    MapLocationModel deleteLocation = _mapLocations.FirstOrDefault(location =>
                        location.ID.Equals(mapPinElement.ID));
                    if (deleteLocation != null)
                        await _mapLocationAccess.Remove(DataSourceType.Sqlite, deleteLocation);

                    _mapPins.Remove(mapPinElement);
                }
            }

            _lastFocusedMapPin = _focusedMapPin;
            _focusedMapPin = mapPinElement;

            if (_lastFocusedMapPin != null)
                _lastFocusedMapPin.UnFocus();

            if (!_focusedMapPin.Focused)
                _focusedMapPin.Focus();
        }
Example #39
0
        private void MapViewViewChanged(object sender,
            ViewChangedEventArgs e)
        {
            foreach (MapPin mapPin in _mapPins)
            {
                if (DataSource.FocusedLocationId != null && DataSource.FocusedLocationId.Value.Equals(mapPin.ID))
                {
                    _focusedMapPin = mapPin;
                    UpdateMapFolderList(DataSource.FocusedLocationId.Value);
                    //DataSource.SelectedStorageFolders = new List<StorageFolder>();

                    mapPin.Focus();
                    DefaultViewModel["Focused"] = true;
                    DataSource.FocusedLocationId = null;
                }
                mapPin.Mark();
            }

            MapView.ViewChanged -= MapViewViewChanged;
        }