Ich verwende Google Maps API für iOS. Ich möchte ein statisches Bild von einer speziellen Stadt bekommen und es in UIImageView einfügen. Wie kann ich es schaffen?Wie bekomme ich ein statisches Bild von Google Maps in iOS
5
A
Antwort
8
die Antwort von @Ankit ist richtig, aber @Alexsander fragte in Swift, so:
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)
+0
@maroc wie den Zoom zu berechnen :( – user3804063
4
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];
Dies sollte helfen.
+0
Ich kenne nur Stadt Name – Alexander
1
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
}
1
Swift Mit 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()
}
+0
wie man Zoom berechnet :( – user3804063
Verwandte Themen
- 1. Wie bekomme ich Höhe von Google Maps
- 2. Wie bekomme ich ein Bild von Google images in Swift?
- 3. Wie bekomme ich Google Maps Objekt in ein Fragment
- 4. Wie bekomme ich Google Maps, um ein ganzes Polygon anzuzeigen?
- 5. iOS Google Maps Frage
- 6. Wie öffne ich Links in Apple Maps oder Google Maps?
- 7. Wie bekomme ich die aktuelle fillColor von Google Maps Polygon?
- 8. Wie bekomme ich ein Bild von Google Api Street View von JQuery ajax Anfrage?
- 9. Verwenden von Google Maps-Steuerelementen für ein großes Bild
- 10. Google Maps: Bild-Overlay aktualisieren
- 11. Wie vergrößere ich ein Bild in iOS?
- 12. Wie ein Google Static Maps Bild mit Javascript
- 13. Holen Sie sich ein Bild von Google Maps
- 14. Google Maps Mehrere Marker.Wie bekomme ich Besondere Marker ID
- 15. Google Maps iOS Polylinien entfernen
- 16. Google Maps iOS SDK Nachtmodus
- 17. Bild in Google Maps V3 drehen?
- 18. Kann ein formatiertes TIFF-Bild in Google Maps eingeblendet werden?
- 19. iOS Google Maps SDK vs MapKit Scrollen
- 20. Google Maps in React-Native (iOS)
- 21. So implementieren Sie iOS Google Maps SDK
- 22. Google Maps Autocomplete: Wie bekomme ich lat/lng?
- 23. Wie bekomme ich alle Markierungen auf google-maps-v3
- 24. Wie erkenne ich Bäume in einem Google Maps-Bild mithilfe der Bildverarbeitung?
- 25. iOS Swift: Wie verkleinere ich ein Bild?
- 26. Wie füge ich ein Bild zu InfoWindow des Markers in Google Maps v3 hinzu?
- 27. "Country" -Eigenschaft fehlt in GMSAutocompleteFilter von Google Maps iOS SDK
- 28. Hinzufügen/Bild dynamisch von Kontrollen in Google Maps V3
- 29. Wie erzwinge ich ein Redraw auf Google Maps API?
- 30. Setzen von Pan Bounds in Google Maps gleich Bild Overlay
Hier Link für Objecive c, können Sie versuchen Sie diese –
Sie können etwas finden Sie hier dann .. https://developers.google.com/maps/documentation/static-maps/?hl=en –