Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Dimitris Togias
2022-09-14 16:07:01 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a6d1d7496b192dcfb7bcad1234a91c8781f113e3
a6d1d749
1 parent
56a37c1d
add directions url
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework/MapsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/MapsViewController.swift
View file @
a6d1d74
...
...
@@ -25,6 +25,7 @@ class MapsViewController: UIViewController, MKMapViewDelegate {
// public
public
var
couponSet
:
swiftApi
.
CouponSetItemModel
?
var
merchantsArray
:
Array
<
swiftApi
.
MerchantModel
>
=
[]
var
selectedMerchant
:
swiftApi
.
MerchantModel
?
//
var
loading
:
Bool
=
false
...
...
@@ -112,6 +113,24 @@ class MapsViewController: UIViewController, MKMapViewDelegate {
@IBAction
func
directionsButtomAction
(
_
sender
:
Any
)
{
guard
let
lon
=
selectedMerchant
?
.
_longitude
,
let
lat
=
selectedMerchant
?
.
_latitude
else
{
return
}
// guard your URL instances
guard
let
googleMapsUrl
=
URL
(
string
:
String
(
format
:
"https://www.google.com/maps/@%.6f,%.6f,6z"
,
lat
,
lon
)),
let
appleMapsUrl
=
URL
(
string
:
String
(
format
:
"http://maps.apple.com/?ll=%.6f,%.6f"
,
lat
,
lon
))
else
{
print
(
"Error creating URLs"
)
return
}
// check if link can be opened with google maps.
guard
UIApplication
.
shared
.
canOpenURL
(
googleMapsUrl
)
else
{
UIApplication
.
shared
.
open
(
appleMapsUrl
,
options
:
[:],
completionHandler
:
nil
)
return
}
UIApplication
.
shared
.
open
(
googleMapsUrl
,
options
:
[:],
completionHandler
:
nil
)
}
private
func
loadMapPins
()
{
...
...
@@ -122,6 +141,8 @@ class MapsViewController: UIViewController, MKMapViewDelegate {
}
private
func
loadPinDetailsView
(
_
annotation
:
MerchantAnnotation
)
{
self
.
selectedMerchant
=
annotation
.
model
self
.
titleView
.
text
=
"INTERSPORT"
self
.
nameImageView
.
image
=
UIImage
(
named
:
"intersport"
)
self
.
nameView
.
text
=
"Intersport Χαλάνδρι"
...
...
@@ -138,6 +159,8 @@ class MapsViewController: UIViewController, MKMapViewDelegate {
}
private
func
hidePinDetailsView
()
{
self
.
selectedMerchant
=
nil
self
.
infoTopConstraint
.
constant
=
0
UIView
.
animate
(
withDuration
:
2.0
)
{
self
.
view
.
layoutIfNeeded
()
...
...
Please
register
or
login
to post a comment