I'm trying to use custom tiles as overlay for google maps.
"https://tile.example.com/hot/{z}/{x}/{y}.png"
I used "GMSTileURLConstructor", but unable to load map on mobile app. I cannot seem to find anything online. Thanks in advance.
I used the following lines.
class ViewController: UIViewController, GMSMapViewDelegate{
let urls: GMSTileURLConstructor = {z,x,y in
let url = "https://tile.example.com/hot/{z}/{x}/{y}.png"
print(url)
return URL(string: url)
}
Related
I am creating a chatting application. User can share the images from other application to my application. I have added Share Extension to show my app in the native share app list. I'm also getting the selected data in didSelectPost Method. From here I want to show the list of the users to whom the image can be forwarded. For this, I'm using an already created view controller in the main app target.
override func didSelectPost() {
// This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
if let content = self.extensionContext!.inputItems[0] as? NSExtensionItem {
let contentType = kUTTypeImage as String
// Verify the provider is valid
if let contents = content.attachments as? [NSItemProvider] {
for attachment in contents {
if attachment.hasItemConformingToTypeIdentifier(contentType) {
attachment.loadItem(forTypeIdentifier: contentType, options: nil) { (data, error) in
let url = data as! URL
let imageData = try! Data(contentsOf: url)
// Here I'm navigating to my viewcontroller, let's say: ForwardVC
}
}
}
}
}
I don't want to recreate the same screen in Share Extension. Apart from this view controllers, I have many more classes and wrappers that I want to use within the share extension. Like, SocketManager, Webservices, etc. Please suggest me your approach to achieve the same.
P.S.: I've tried setting multiple targets to required viewControllers and using same pods for Share Extention. In this approach, I'm facing a lot of issues as many of the methods and pods are not extention compliant. Also, is it the right way to do this.
I am implementing Firebase dynamic links in my iOS project. It is working fine and it is opening my iOS Home screen properly. But now I would like to extract values from url and open appropriate screen based on url.
for example:
https://www.dd.com/forums/hot-deals-online/topics/smart-tv-carniva
in this url I would like to get 'hot-deals-online' and 'smart-tv-carniva' permalink which I will pass to view controller to open that screen on the app
can someone suggest me best approach for this.
Shortest is to access path of URLComponents object:
let url = "https://www.dd.com/forums/hot-deals-online/topics/smart-tv-carniva"
if let comps = URLComponents(string: url) {
var elements = comps.path.split(separator: "/").map(String.init)
// ["forums", "hot-deals-online", "topics", "smart-tv-carniva"]
// To build an url back, example:
var url = URL(string: comps.host!)!
url.appendPathComponent(elements[0])
url.appendPathComponent(elements[1])
// Result: www.dd.com/forums/hot-deals-online
}
P.S. calling .map(String.init) makes in-place conversion from array of substrings to normal String array.
I am new to iOS development. In my project i am displaying a exerciseFilePath on tableview.
the response is given below.
"exerciseId" : 1,
"exerciseName" : "Fitness Exercise",
"exerciseFilePath" : "\/p\/pdf\/exercise_pdf\/fitness_exercise.pdf"
i need to display the pdf in another view on didSelectRowAtIndexpath.
i Dont know how to display the pdf and what are steps to be followed to display that pdf.
I hope you understand my problem. please help me how I can do this.
Why don't you use QLPreviewController or UIDocumentInteractionController?
Now in your case you can do it by using webView:
let req = NSURLRequest(url: pdf) //pdf is your pdf path
let webView = UIWebView(frame: CGRect(x:0,y:0,width:self.view.frame.size.width,height: self.view.frame.size.height-40)) //Adjust view area here
webView.loadRequest(req as URLRequest)
self.view.addSubview(webView)
Some tutorials:
QLPreviewController example
UIDocumentInteractionController example
In my Firebase database, I have a 'link' with some URL of a video as a value.
I'm trying to call it it via:
enum Media {
static let videoURL = "linkLabel.text = posts[selectedIndexPath].link"
}
Without success. If I call it just as a label text, it is fine. However, I also try the following:
static let videoURL = URL(string: "linkLabel.text = posts[selectedIndexPath].link")
As well as trying to call from my super.viewDidload() like:
videoVRView.load(from: URL(string: "\(linkLabel.text = posts[selectedIndexPath].link)"))
Anybody would know how to achieve this correctly? It will be amazing! Thanks!
----- EDIT:
I got it work by videoVRView.load(from: URL(string: "\(posts[selectedIndexPath].link)"))
I'm working on a iOS project with Swift on Xcode, and i need to show a map with some routes drawn on it. I created the map view using Google Maps SDK for iOS and it works well. I use KML.swift to parse the KML file.
The problem is that i want to load the routes for the map from a KML and i don't see how to do it. On Android, the SDK allows you to add a layer from a KML and add that layer to the map easy (more or less), but i can't find the way to do something like that on the iOS SDK.
Is there any way to do it?
Thanks in advance.
You can now do so with GoogleMapsUtils. The KML file can be parsed using GMUKMLParser and rendered with GMSMapView.
Create instances of GMSMapView and GMUKMLParser
let mapView: GMSMapView!
let kmlParser: GMUKMLParser!
func renderKml() {
guard let path = Bundle.main.path(forResource: "uae_map", ofType: "kml") else {
print("Invalid path")
return
}
let url = URL(fileURLWithPath: path)
kmlParser = GMUKMLParser(url: url)
kmlParser.parse()
let renderer = GMUGeometryRenderer(
map: mapView,
geometries: kmlParser.placemarks,
styles: kmlParser.styles,
styleMaps: kmlParser.styleMaps
)
renderer.render()
}