Using Google Maps API to get Address of Business

后端 未结 3 1714
闹比i
闹比i 2020-12-28 18:32

I have a requirement and I am hoping Google Maps API will have a solution. I have never used Google Maps API - so I am very new to this.

On the website homepage ther

3条回答
  •  天命终不由人
    2020-12-28 18:54

    updated: here is an example of using the google clientlocation api and localsearch using jsonp.


    
    
        
    
        
    
        
    
        
    
        
    
    
    
        
    latitude :
    longitude :
    city :
    region :
    country :
    country_code :

     

    // 
    // This source is placed in the Public Domain.
    // http://skysanders.net/subtext
    // Attribution is appreciated.
    // 
    
    
    /*
    object literal format for google.loader.clientlocation  
    {
    "latitude": 33.324,
    "longitude": -111.867,
    "address": {
    "city": "Chandler",
    "region": "AZ",
    "country": "USA",
    "country_code": "US"
    }
    }
    */
    
    var ClientLocation = {};
    
    ClientLocation.Address = function() {
        /// 
        /// 
        /// 
        /// 
        /// 
        if (arguments.length > 0) {
            this.city = arguments[0].city;
            this.region = arguments[0].region;
            this.country = arguments[0].country;
            this.country_code = arguments[0].country_code;
            return;
        }
        else {
            this.city = "";
            this.region = "";
            this.country = "";
            this.country_code = "";
        }
    
    }
    ClientLocation.Location = function() {
        /// 
        /// 
        /// 
        if (arguments.length > 0) {
    
            this.latitude = arguments[0].latitude;
            this.longitude = arguments[0].longitude;
            this.address = arguments[0].address;
    
        }
        else {
            this.latitude = 0;
            this.longitude = 0;
            this.address = undefined;
        }
    
    }
    
    
    // 
    // This source is placed in the Public Domain.
    // http://skysanders.net/subtext
    // Attribution is appreciated.
    // 
    /*
    GlocalSearch result
    
    {
    "GsearchResultClass": "GlocalSearch",
    "viewportmode": "computed",
    "listingType": "local",
    "lat": "33.389689",
    "lng": "-111.853909",
    "accuracy": "8",
    "title": "Best \u003cb\u003eBuy\u003c/b\u003e",
    "titleNoFormatting": "Best Buy",
    "ddUrl": "http://www.google.com/maps....",
    "ddUrlToHere": "http://www.google.com/maps?....",
    "ddUrlFromHere": "http://www.google.com/maps?....",
    "streetAddress": "1337 South Alma School Road",
    "city": "Mesa",
    "region": "AZ",
    "country": "United States",
    "staticMapUrl": "http://mt.google.com/mapdata?....",
    "url": "http://www.google.com/maps/place?source....",
    "content": "",
    "maxAge": 604800,
    "phoneNumbers": [{
    "type": "",
    "number": "(480) 644-7139"
    },
    {
    "type": "",
    "number": "(480) 464-0444"
    }],
    "addressLines": ["1337 South Alma School Road", "Mesa, AZ"]
    }
    
    */
    
    
    var LocalSearch = {};
    
    LocalSearch.PhoneNumber = function() {
        /// 
        /// 
        /// 
    
        if (arguments.length > 0) {
            this.type = arguments[0].type;
            this.number = arguments[0].number;
        }
        else {
            this.type = "";
            this.number = "";
        }
    }
    
    
    
    LocalSearch.Result = function() {
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        // 
        if (arguments.length > 0) {
            this.GsearchResultClass = arguments[0].GsearchResultClass;
            this.viewportmode = arguments[0].viewportmode;
            this.listingType = arguments[0].listingType;
            this.lat = arguments[0].lat;
            this.lng = arguments[0].lng;
            this.accuracy = arguments[0].accuracy;
            this.title = arguments[0].title;
            this.titleNoFormatting = arguments[0].titleNoFormatting;
            this.ddUrl = arguments[0].ddUrl;
            this.ddUrlToHere = arguments[0].ddUrlToHere;
            this.ddUrlFromHere = arguments[0].ddUrlFromHere;
            this.streetAddress = arguments[0].streetAddress;
            this.city = arguments[0].city;
            this.region = arguments[0].region;
            this.country = arguments[0].country;
            this.staticMapUrl = arguments[0].staticMapUrl;
            this.url = arguments[0].url;
            this.content = arguments[0].content;
            this.maxAge = arguments[0].maxAge;
            this.phoneNumbers = arguments[0].phoneNumbers;
            this.addressLines = arguments[0].addressLines;
    
        }
        else {
    
            this.GsearchResultClass = "";
            this.viewportmode = "";
            this.listingType = "";
            this.lat = "";
            this.lng = "";
            this.accuracy = "";
            this.title = "";
            this.titleNoFormatting = "";
            this.ddUrl = "";
            this.ddUrlToHere = "";
            this.ddUrlFromHere = "";
            this.streetAddress = "";
            this.city = "";
            this.region = "";
            this.country = "";
            this.staticMapUrl = "";
            this.url = "";
            this.content = "";
            this.maxAge = 0;
            this.phoneNumbers = [];
            this.addressLines = [];
        }
    
    
    }
    

提交回复
热议问题