ios - Placing marker of bus station on googlemap -
i having trouble placing marker of bus station near me on google map application.
let live in new york city,i want bus station marker on google map.but,i don't know how fetch bus station data of current city(new york) , place picker on it.i tried appcoda tutorial , gives me marker of custom search
here : http://www.appcoda.com/google-maps-api-tutorial/
is there way can modified "maptask.swift" code bus station near me , place picker on each bus station?
here maptask.swift
import uikit import corelocation import swiftyjson class maptask: nsobject { let baseurlgeocode = "https://maps.googleapis.com/maps/api/geocode/json?" var lookupaddressresults: dictionary<nsobject, anyobject>! var fetchedformattedaddress: string! var fetchedaddresslongitude: double! var fetchedaddresslatitude: double! override init() { super.init() } func geocodeaddress(address: string!, withcompletionhandler completionhandler: ((status: string, success: bool) -> void)) { if let lookupaddress = address { var geocodeurlstring = baseurlgeocode + "address=" + lookupaddress geocodeurlstring = geocodeurlstring.stringbyaddingpercentescapesusingencoding(nsutf8stringencoding)! let geocodeurl = nsurl(string: geocodeurlstring) dispatch_async(dispatch_get_main_queue(), { () -> void in let geocodingresultsdata = nsdata(contentsofurl: geocodeurl!) let dictionary: dictionary<nsobject, anyobject> = try!nsjsonserialization.jsonobjectwithdata(geocodingresultsdata!, options: nsjsonreadingoptions.mutablecontainers) as! dictionary<nsobject, anyobject> // response status. let status = dictionary["status"] as! string if status == "ok" { let allresults = dictionary["results"] as! array<dictionary<nsobject, anyobject>> self.lookupaddressresults = allresults[0] print("the result : \(dictionary)") // keep important values. self.fetchedformattedaddress = self.lookupaddressresults["formatted_address"] as! string let geometry = self.lookupaddressresults["geometry"] as! dictionary<nsobject, anyobject> self.fetchedaddresslongitude = ((geometry["location"] as! dictionary<nsobject, anyobject>)["lng"] as! nsnumber).doublevalue self.fetchedaddresslatitude = ((geometry["location"] as! dictionary<nsobject, anyobject>)["lat"] as! nsnumber).doublevalue completionhandler(status: status, success: true) } else { completionhandler(status: status, success: false) } }) } else { completionhandler(status: "no valid address.", success: false) } } }
you'll need call place search type
set bus_station
limit return specific type. response return results
details can use set markers.
Comments
Post a Comment