I am trying to use the google map street view in my app, so i am trying to load the html file in my Webview. but it is need the flash player to show the street view.
Is adobe flash player is required for this?
Anyone know how to use the street view in our iphone app?
Regards,
Yes, it is possible to load Google StreetView in UIWebView. Here is a sample code example to load Google StreetView -
let urlAddress = "http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=bran+castle&sll=44.439972,26.096894&sspn=0.000869,0.003664&ie=UTF8&hq=Bran+Castle&hnear=Bran+Castle,+Strada+General+Traian+Mo%C8%99oiu+nr.+28+E574,+Bran+507025,+Romania&t=k&layer=c&cbll=45.516381,25.368123&panoid=0d7jjq7vdWGTxFyonEKnBQ&cbp=12,209.81,,1,-18.52&ll=45.516381,25.368123&spn=0,0.008444&z=17";
let request = NSURLRequest(URL: NSURL(string: urlAddress)!)
glWebView.loadRequest(request)
After loading this streetView. Google will give you an alert that this URL is belongs to google map only. To hide that alert message just add this below javascript query in your WebViewDidFinish method -
webView.stringByEvaluatingJavaScriptFromString("document.getElementsByClassName('ml-unsupported-link-dialog-container')[0].style.display='none'")
Well technically it is not possible, but if you can get the panorama image id for that specific latitude and longitude, then it is possible. In my previous answer, I said it is possible as because I know the panorama id for that specific location. Using that code you can open steetview in your UIWebview, but it will show a warning. By touching anywhere in your webview will disappear that warning alert.
Bu Google introduce there SDK to load streetview in your iOS app, instead of leaving your app. All you need to do is add 'GoogleMaps' sdk using cocoa pods and run this below source code to display google Streetview for specific latitude and longitude.
let panoSvc = GMSPanoramaService()
panoSvc.requestPanoramaNearCoordinate(CLLocationCoordinate2D(latitude: 32.847683, longitude: -96.771638), radius:100, callback: { (panorama, error) in
if error == nil {
DispatchQueue.main.async(execute: {
let panoView = GMSPanoramaView(frame: .zero)
self.view = panoView
panoView.moveNearCoordinate((panorama?.coordinate)!, radius: 200)
print("Panorama ID: ", panorama?.panoramaID)
print("Panorama Co-ordinate: ", panorama?.coordinate)
})
}
else {
Utility.showCustomMsg(self.view, label: "Not Found", detailslbl:"Street View is not available for this location.", isSuccessImg: false, duration: 3)
{
self.navigationController?.popViewController(animated: true)
}
}
})
Cool huh...... Thanks goes to Google for their cool staff.
Related
I'm not able to receive image dragged from Safari webpage in my SwiftUI app on macOS. I suppose Safari uses different mechanics, because it works properly when it comes to Chrome and Firefox. I use .onDrop() but it results empty providers no matter what kind of UTType used. Below is my code but output no provider available.
So, what UTType it is when dragging image from Safari webpage, and how can I implement it in .onDrop()
.onDrop(of: [.url, .fileURL], isTargeted: $isTarget) { providers -> Bool in
if let provider = providers.first,
let identifier = provider.registeredTypeIdentifiers.first {
print(identifier)
provider.loadItem(forTypeIdentifier: identifier) { data, error in
// Do something here
}
} else {
print("no provider available")
}
return true
}
How can I enable turn-by-turn navigation with google maps urlscheme?. I used below url in swift
comgooglemaps://?saddr=%f,%f&daddr=%f,%f&directionsmode=driving
but it only creates a route, the start navigation button is not present when the google maps app is activated.
am i missing something?
let kGoogleMapsSchema = "comgooglemaps://"
let path = "\(kGoogleMapsSchema)?saddr=%f,%f&daddr=%f,%f&directionsmode=driving"
guard let finalURLString = String(format: path, currentUserCoordinates!.latitude, currentUserCoordinates!.longitude, destinationCoordinates!.latitude, destinationCoordinates!.longitude, currentUserCoordinates!.latitude, currentUserCoordinates!.longitude).addingPercentEncoding(
withAllowedCharacters: .urlQueryAllowed) else {
return
}
guard let url = URL(string: finalURLString) else {
return
}
if #available(iOS 10, *) {
UIApplication.shared.open(url)
} else {
UIApplication.shared.openURL(url)
}
am i missing something?
I found the answer as only preview button was available instead of start navigation. Because I was giving start coordinates not of my current location. So in case it is my current coordinates it will work.
Google Maps, No Option for Starting the Navigation, Only Preview is there
I've never worked in WatchOS5 and want to develop a horizontal complication (Modular large) for AppleWatch, like "Heart Rate". The idea is that I would display heart rate data in a different way. Right now I want to deploy the complication on development watch.
I have created a new project with a checkbox for "complication" added. I see that this added a complications controller with timeline configuration placeholders.
There is also an storyboard with a bunch of empty screens. I'm not sure as to how much effort I need to put into an apple watch app before I can deploy it. I see this Apple doc, but it does not describe how to layout my complication. Some section seem to have missing links.
Can I provide one style of complication only (large horizontal - modular large)
Do I need to provide any iPhone app content beyond managing the
complication logic, or can I get away without having a view controller?
Do I control the appearance of my complication by adding something to the assets folder (it has a bunch of graphic slots)?
Sorry for a complete beginner project, I have not seen a project focusing specifically on the horizontal complication for watch OS 5
You should be able to deploy it immediately, though it won't do anything. Have a look at the wwdc video explaining how to create a complication: video
You can't layout the complication yourself, you can chose from a set of templates that you fill with data. The screens you are seeing are for your watch app, not the complication.
You don't have to support all complication styles.
The complication logic is part of your WatchKit Extension, so technically you don't need anything in the iOS companion app, I'm not sure how much functionality you have to provide to get past the app review though.
Adding your graphics to the asset catalog won't do anything, you have to reference them when configuring the templates.
Here's an example by Apple of how to communicate with the apple watch app. You need to painstakingly read the readme about 25 times to get all the app group identifiers changed in that project.
Your main phone app assets are not visible to the watch app
Your watch storyboard assets go in WatchKit target
Your programmatically accessed assets go into the watch extension target
Original answers:
Can I provide one style of complication only (large horizontal -
modular large) - YES
Do I need to provide any iPhone app content beyond
managing the complication logic, or can I get away without having a
view controller? YES - watch apps have computation limits imposed on them
Do I control the appearance of my complication by
adding something to the assets folder (it has a bunch of graphic
slots)? See below - it's both assets folder and placeholders
Modify the example above to create a placeholder image displayed on the watch (when you are selecting a complication while modifying the screen layout)
func getPlaceholderTemplate(for complication: CLKComplication, withHandler handler: #escaping (CLKComplicationTemplate?) -> Void) {
// Pass the template to ClockKit.
if complication.family == .graphicRectangular {
// Display a random number string on the body.
let template = CLKComplicationTemplateGraphicRectangularLargeImage()
template.textProvider = CLKSimpleTextProvider(text: "---")
let image = UIImage(named: "imageFromWatchExtensionAssets") ?? UIImage()
template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
// Pass the entry to ClockKit.
handler(template)
}else {
handler(nil);
return
}
}
sending small packets to the watch (will not send images!)
func updateHeartRate(with sample: HKQuantitySample){
let context: [String: Any] = ["title": "String from phone"]
do {
try WCSession.default.updateApplicationContext(context)
} catch {
print("Failed to transmit app context")
}
}
Transferring images and files:
func uploadImage(_ image: UIImage, name: String, title: String = "") {
let data: Data? = UIImagePNGRepresentation(image)
do {
let fileManager = FileManager.default
let documentDirectory = try fileManager.url(for: .cachesDirectory,
in: .userDomainMask,
appropriateFor:nil,
create:true)
let fileURL = try FileManager.fileURL("\(name).png")
if fileManager.fileExists(atPath: fileURL.path) {
try fileManager.removeItem(at: fileURL)
try data?.write(to: fileURL, options: Data.WritingOptions.atomic)
} else {
try data?.write(to: fileURL, options: Data.WritingOptions.atomic)
}
if WCSession.default.activationState != .activated {
print("session not activated")
}
fileTransfer = WCSession.default.transferFile(fileURL, metadata: ["name":name, "title": title])
}
catch {
print(error)
}
print("Completed transfer \(name)")
}
I have plotted a marker in a Google Map, now i want to share that location to my friends via url/link. how to create link of that location in swift.
The use of this is if my friends click on that url/link, it will take to that location in a Google Map. I dont have any idea about it. the below code shows how i created a marker:
let position = CLLocationCoordinate2DMake(latitude,longitude)
let location = GMSMarker(position: position)
location.icon = image
location.icon = self.imageWithImage(image, scaledToSize: CGSize(width: 30.0, height: 30.0))
location.title = "the photo is clicked here"
location.map = MapView
To launch Apple Maps or Google Maps you need to create an NSURL.
let targetURL = NSURL(string: "http://maps.apple.com/?q=FartCity")!
https://developers.google.com/maps/documentation/ios-sdk/urlscheme
let targetURL = NSURL(string: "comgooglemaps://?q=FartCity")!
Check that the user has the correct map app by checking if the url can be handled.
let isAvailable = UIApplication.sharedApplication().canOpenURL(targetURL)
open the url
UIApplication.sharedApplication().openURL(targetURL)
im working on an App for iOS where I embedded the new Google Map for native iOS. Everything works fine except one problem where I canĀ“t find a propper solution for native IOS/ swift neither here nor at google (if there is one please show me and sorry for annoying you)
I need get location fro new position when change marker location in map
How can I do that?
Thanks for advices
Finally solve using this function :
func mapView(mapViewUIView: GMSMapView!, didTapAtCoordinate coordinate: CLLocationCoordinate2D) {
marker.position.latitude = coordinate.latitude
marker.position.longitude = coordinate.longitude
println(marker.position.latitude)
let ULlocation = marker.position.latitude
let ULlgocation = marker.position.longitude
}