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
e4fa5511
Unverified
Commit
e4fa5511
authored
Jul 05, 2021
by
ASAHI OCEAN
Committed by
GitHub
Jul 05, 2021
Browse files
Merge pull request #20 from asahiocean/develop
Develop
parents
1568ca1f
1d514cf9
Changes
4
Hide whitespace changes
Inline
Side-by-side
SZRCAI/SZRCAI/Main code/Controllers/ViewController/Delegates/MKMapViewDelegate+ViewController.swift
View file @
e4fa5511
import
Foundation
import
UIKit
import
MapKit
...
...
@@ -40,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
)
{
...
...
@@ -48,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
}
}
}
...
...
@@ -59,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
...
...
@@ -72,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
()
...
...
SZRCAI/SZRCAI/Main code/Controllers/ViewController/Delegates/ModelDelegate+ViewController.swift
View file @
e4fa5511
...
...
@@ -37,7 +37,7 @@ extension ViewController: ModelDelegate {
let
coords
=
mapView
.
model
.
route
.
compactMap
({
$0
.
coordinate
})
for
(
i
,
coord
)
in
coords
.
enumerated
()
{
if
(
i
+
1
)
<
coords
.
count
{
if
(
i
+
1
)
<
coords
.
count
{
createRouteTo
(
from
:
coord
,
to
:
coords
[
i
+
1
])
}
}
...
...
SZRCAI/SZRCAI/Main code/Controllers/ViewController/ViewController.swift
View file @
e4fa5511
...
...
@@ -5,6 +5,7 @@ import UIKit
class
ViewController
:
UIViewController
{
var
mapView
:
MapView
!
internal
var
model
=
Model
.
shared
/// Button for building graphs and routes
weak
var
mainButton
:
UIButton
!
...
...
SZRCAI/SZRCAI/Main code/Model/Model.swift
View file @
e4fa5511
...
...
@@ -21,8 +21,8 @@ protocol ModelDelegate: AnyObject {
@objc
dynamic
var
selected
:
PinAnnotation
?
public
var
route
:
[
PinAnnotation
]
=
[]
var
selectedPinsKVO
:
NSKeyValueObservation
!
var
mainButtonTitle
:
String
=
""
// To save the button name
internal
var
selectedPinsKVO
:
NSKeyValueObservation
!
internal
var
mainButtonTitle
:
String
=
""
// To save the button name
fileprivate
override
init
()
{
super
.
init
()
...
...
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