Uso google maps api per iOS. Voglio ottenere un'immagine statica della città speciale e incollarla in UIImageView. Come posso farcela?Come ottenere immagini statiche da google maps in iOS
risposta
la risposta di @Ankit è giusto, ma @Alexsander chiesto a Swift, quindi:
var staticMapUrl: String = "http://maps.google.com/maps/api/staticmap?markers=color:blue|\(self.staticData.latitude),\(self.staticData.longitude)&\("zoom=13&size=\(2 * Int(mapFrame.size.width))\(2 * Int(mapFrame.size.height))")&sensor=true"
var mapUrl: NSURL = NSURL(string: staticMapUrl.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding))!
var image: UIImage = UIImage.imageWithData(NSData.dataWithContentsOfURL(mapUrl))
var mapImage: UIImageView = UIImageView(frame: mapFrame)
@maroc come calcolare lo zoom :( – user3804063
NSString *staticMapUrl = [NSString stringWithFormat:@"http://maps.google.com/maps/api/staticmap?markers=color:blue|%@,%@&%@&sensor=true",self.staticData.latitude, self.staticData.longitude, [NSString stringWithFormat:@"zoom=13&size=%dx%d",2*(int)mapFrame.size.width, 2*(int)mapFrame.size.height]];
NSURL *mapUrl = [NSURL URLWithString:[staticMapUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:mapUrl]];
UIImageView *mapImage = [[UIImageView alloc] initWithFrame:mapFrame];
Questo dovrebbe aiutare.
So solo il nome della città – Alexander
Swift 3 =>
let Width = 100
let Height = 200
let mapImageUrl = "https://maps.googleapis.com/maps/api/staticmap?center="
let latlong = "18.495651759752, 73.809987567365"
let mapUrl = mapImageUrl + latlong
let size = "&size=" + "\(Int(Width))" + "x" + "\(Int(Height))"
let positionOnMap = "&markers=size:mid|color:red|" + latlong
let staticImageUrl = mapUrl + size + positionOnMap
if let urlStr : NSString = staticImageUrl.addingPercentEscapes(using:String.Encoding.utf8)! as NSString{
// setImageFromURL
}
Utilizzando Swift 3:
let lat = ..
let long = ..
let staticMapUrl: String = "http://maps.google.com/maps/api/staticmap?markers=color:red|\(lat),\(long)&\("zoom=13&size=\(2 * Int(cell.imgAddress.frame.size.width))x\(2 * Int(cell.imgAddress.frame.size.height))")&sensor=true"
let url = URL(string: staticMapUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)
do {
let data = try NSData(contentsOf: url!, options: NSData.ReadingOptions())
cell.imgAddress.image = UIImage(data: data as Data)
} catch {
cell.imgAddress.image = UIImage()
}
come calcolare lo zoom :( – user3804063
- 1. posso ottenere mappe statiche nell'API di Google Maps API V3?
- 2. Rimuovi i marker da google maps iOS
- 3. Google Maps: LocationSource personalizzata in iOS
- 4. Ottenere risposta ZERO_RESULTS da GEOLocation di Google in iOS.
- 5. È consentito memorizzare nella cache le google maps statiche?
- 6. Sfarfallio di Google Maps in iOS
- 7. Google Maps in React-Native (iOS)
- 8. Apri l'app Google Maps in iOS 6
- 9. Ottenere coordinate da "Condividi questo luogo" in Google Maps
- 10. API di Google Maps directionsService.route diverso da Google Maps Indicazioni
- 11. Ottenere Google Maps API key
- 12. Google Maps Streetview - Come ottenere l'ID Panorama
- 13. Come aprire i collegamenti in Apple Maps o Google Maps?
- 14. Come faccio ad animare GMSPolyline in google maps ios
- 15. iOS google maps posizionamento sdk GMSMarker
- 16. iOS Google Maps Api Sovrapposti piastrellati
- 17. Modalità notte SDK iOS di Google Maps
- 18. È possibile ottenere percorsi suggeriti da google maps nell'applicazione android2.2?
- 19. Pop Immagini come Google Immagini
- 20. Google Maps come sfondo
- 21. Rimuovi rettangolo da Google Maps
- 22. Ottenere una chiave API v2 Google Maps
- 23. Google Maps API vs Google Maps Engine?
- 24. Come implementare l'SDK di Google Maps per iOS
- 25. Ottenere immagini da ImageView
- 26. Come integrare la nuova app Google Maps con l'app ios
- 27. Punto posizione su Google Maps iOS SDK visualizzato come quadrato
- 28. Controllo Animazione Durata in Google Maps per iOS
- 29. Come scattare diverse immagini da Camera ios
- 30. iOS: Come abilitare le indicazioni audio su Google Maps
Ecco collegamento per Objecive c, è possibile prova questo –
potresti trovare qualcosa qui allora .. https://developers.google.com/maps/documentation/static-maps/?hl=it –