Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
asahiocean
SZRCAI
Commits
07b606af
Verified
Commit
07b606af
authored
Jul 05, 2021
by
asahiocean
🚀
Browse files
internal model
parent
27dfe5b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
SZRCAI/SZRCAI/Main code/Controllers/ViewController/Delegates/MKMapViewDelegate+ViewController.swift
View file @
07b606af
...
...
@@ -39,7 +39,7 @@ extension ViewController: MKMapViewDelegate {
func
mapView
(
_
mapView
:
MKMapView
,
didDeselect
view
:
MKAnnotationView
)
{
guard
let
annotation
=
view
.
annotation
else
{
return
}
mapView
.
deselectAnnotation
(
annotation
,
animated
:
true
)
Model
.
shared
.
selected
=
nil
self
.
model
.
selected
=
nil
}
func
mapView
(
_
mapView
:
MKMapView
,
didSelect
view
:
MKAnnotationView
)
{
...
...
@@ -47,7 +47,7 @@ extension ViewController: MKMapViewDelegate {
if
let
pin
=
annotation
as?
PinAnnotation
{
mapView
.
selectAnnotation
(
pin
,
animated
:
true
)
// If the graph is built, give the opportunity to choose the starting and ending point
if
Model
.
shared
.
graphsBuilt
{
Model
.
shared
.
selected
=
pin
}
if
self
.
model
.
graphsBuilt
{
self
.
model
.
selected
=
pin
}
}
}
...
...
@@ -58,7 +58,7 @@ extension ViewController: MKMapViewDelegate {
case
let
pin
as
PinAnnotation
:
let
id
=
PinMarkerView
.
reuseId
let
view
=
mapView
.
dequeueReusableAnnotationView
(
withIdentifier
:
id
,
for
:
pin
)
Model
.
shared
.
pins
.
append
(
pin
)
self
.
model
.
pins
.
append
(
pin
)
return
view
default
:
return
nil
...
...
@@ -71,8 +71,8 @@ extension ViewController: MKMapViewDelegate {
switch
view
.
annotation
{
case
let
pin
as
PinAnnotation
:
guard
let
annotation
=
view
.
annotation
else
{
return
}
Model
.
shared
.
pins
.
removeAll
(
where
:
{
$0
==
pin
})
Model
.
shared
.
route
.
removeAll
(
where
:
{
$0
==
pin
})
self
.
model
.
pins
.
removeAll
(
where
:
{
$0
==
pin
})
self
.
model
.
route
.
removeAll
(
where
:
{
$0
==
pin
})
mapView
.
removeAnnotation
(
annotation
)
// After removing the marker, the graphs will be rebuilt
self
.
constructGraphs
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment