2010-02-16 23 views
13

मुझे एक आवश्यकता है और मुझे उम्मीद है कि Google मानचित्र API का समाधान होगा। मैंने कभी भी Google मानचित्र API का उपयोग नहीं किया है - इसलिए मैं इसके लिए बहुत नया हूं।व्यवसाय का पता पाने के लिए Google मानचित्र API का उपयोग

वेबसाइट के मुखपृष्ठ वहाँ एक रूप है, एक उपयोगकर्ता आता है जब, मैं निम्नलिखित बातें होती हैं करना चाहते हैं पर:

1) शहर क्षेत्र उपयोगकर्ताओं आईपी

2 के आधार पर शहर के साथ आबादी वाले किया जाना चाहिए) स्टोर नाम नामक दूसरा क्षेत्र है - जब उपयोगकर्ता स्टोर नाम टाइप करना शुरू करता है - मैं उस शहर के साथ उस व्यवसाय के साथ सभी व्यावसायिक लिस्टिंग प्राप्त करना चाहता हूं और इसे एक ड्रॉप डाउन के रूप में दिखाता हूं जिससे उपयोगकर्ता उपयुक्त शाखा का चयन कर सकता है। मानचित्र पर कुछ भी दिखाने की ज़रूरत नहीं है। ईजीएस - ह्यूस्टन में एक उपयोगकर्ता McDonalds टाइपिंग शुरू होता है, तो निम्न व्यापार लिस्टिंग

दिखाने शुरू कर देना चाहिए
  • McDonalds, 12 Pearland एवेन्यू, Houston TX
  • McDonalds, 2600 Bary क्षेत्र बुलेवार्ड, Houston TX
  • McDonalds, 262 Clearlake बुलेवार्ड, Houston TX

इसके अलावा जब हम गूगल एपीआई से एक व्यावसायिक प्रविष्टि के लिए पता है - हम एक स्ट्रिंग के रूप में यह मिलता है और हम इसे पार्स करने के लिए की जरूरत है या करना हम इसे विभिन्न क्षेत्रों सड़क का नाम, शहर प्राप्त , राज्य, ज़िप कोड आदि

किसी भी जानकारी या उदाहरणों की वास्तव में सराहना की जाएगी धन्यवाद

+0

मैं एक नमूना खुद को और दूसरों के द्वारा संदर्भ के लिए ग्राहक उस चीज़ की इस तरह की तलाश में आते हैं करने के लिए स्थानीय व्यापारों लाने के लिए दोनों ग्राहक स्थान और स्थानीय खोज का उपयोग कर गयी। –

उत्तर

14

मुझे नहीं लगता कि आप Google मानचित्र चाहते हैं। उपयोग की जाने वाली सभी शर्तों में सार्वजनिक रूप से सुलभ वेबपृष्ठ पर Google मानचित्र पर चीजों को प्रदर्शित करने के अलावा किसी भी अन्य उपयोग की अनुमति नहीं है, दूसरा, एक और Google एपीआई है जो आपको वही करता है जो आपको चाहिए: क्लाइंट स्थान API: http://code.google.com/apis/ajax/documentation/#ClientLocation

"व्यवसाय" के बारे में: आपको उस डेटा को कहीं से स्रोत करना होगा - मुझे विश्वास नहीं है कि इसके लिए Google की सेवा है। शायद आप बस Google खोज API और कुछ तर्क इस्तेमाल कर सकते हैं केवल व्यवसायों को खोजने के लिए (http://code.google.com/apis/ajaxsearch/)

संपादित करें: http://code.google.com/apis/ajaxsearch/samples.html#local-search

+0

+1 सही उत्तर –

+1

हैलो रोलैंड आपकी प्रतिक्रिया के लिए धन्यवाद - जब मेरा व्यवसाय है - मैं उन व्यवसायों के बारे में बात कर रहा हूं जो पहले से ही Google स्थानीय खोज पर दिखाई देते हैं। उदाहरण के लिए यदि आप http://maps.google.co पर जाते हैं।मैकडॉनल्ड्स ह्यूस्टन में/और खोज करें - यह आपको निम्नलिखित परिणाम दिखाएगा: 2017 मेन स्ट्रीट, ह्यूस्टन, TX, संयुक्त राज्य अमेरिका 808 डलास स्ट्रीट, ह्यूस्टन, TX, संयुक्त राज्य अमेरिका 4005 एल्गिन स्ट्रीट, ह्यूस्टन, TX, संयुक्त राज्य अमेरिका इसलिए यदि मैं "एमसीडॉनल्ड्स" और "ह्यूस्टन" पास करता हूं तो हम Google से यह जानकारी नहीं प्राप्त कर सकते हैं। धन्यवाद – Gublooo

+0

ओह - मुझे खेद है कि मैंने आपके संपादन नोट को अभी नहीं देखा है। – Gublooo

3

अद्यतन:: मैं व्यवसायों के लिए, शायद आप एक बार देख इस नमूने में ले सकता है यहाँ एक है google clientlocation api और jsonp का उपयोग कर स्थानीय खोज का उपयोग करने का उदाहरण।


<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 

    <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAALDWeTDQHOJCbCf0JnUqL8BT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQA7AE8xB9MyWgHECPY2qimOp7BUQ"></script> 

    <script src="scripts/clientLocation.js" type="text/javascript"></script> 

    <script src="scripts/localSearch.js" type="text/javascript"></script> 

    <script type="text/javascript"> 



     function $g(id) { 
      return document.getElementById(id); 
     } 

     function displayLocation(latitudeEl, longitudeEl, cityEl, regionEl, countryEl, country_codeEl) { 
      var cloc = new ClientLocation.Location(google.loader.ClientLocation); 
      if (latitudeEl) latitudeEl.innerHTML = cloc.latitude; 
      if (longitudeEl) longitudeEl.innerHTML = cloc.longitude; 
      if (cityEl) cityEl.innerHTML = cloc.address.city; 
      if (regionEl) regionEl.innerHTML = cloc.address.region; 
      if (country) country.innerHTML = cloc.address.country; 
      if (country_codeEl) country_codeEl.innerHTML = cloc.address.country_code; 
     } 
     function localSearch(term, callback, context) { 
      var cloc = new ClientLocation.Location(google.loader.ClientLocation); 
      var searchUrl = 'http://www.google.com/uds/GlocalSearch?callback=' + callback + '&context=' + context + '&hl=en&q=' + encodeURIComponent(term) + '&sll=' + cloc.latitude + ',' + cloc.longitude + '&key=ABQIAAAALDWeTDQHOJCbCf0JnUqL8BT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQA7AE8xB9MyWgHECPY2qimOp7BUQ&v=1.0'; 

      // http://jaybyjayfresh.com/2007/09/17/using-script-tags-to-do-remote-http-calls-in-javascript/ 
      scriptLoaded = function() { 
       removeNode(newScript); 
      }; 

      var headID = document.getElementsByTagName("head")[0]; 
      var newScript = document.createElement('script'); 
      newScript.type = 'text/javascript'; 
      newScript.onload = scriptLoaded; 
      newScript.src = searchUrl; 
      headID.appendChild(newScript); 
     } 
     function search() { 
      var term = $g("txtSearch").value; 
      localSearch(term, "displayResults", "0"); 

     } 
     function displayResults(context, results, status, details, unused) { 
      var titles = []; 
      for (var i = 0; i < results.results.length; i++) { 
       // this cast is not necessary, just here to illustrate 
       // vs intellisense and reduce coding errors. 
       var result = new LocalSearch.Result(results.results[i]); 
       titles.push(result.title); 
      } 
      $g("searchResults").innerHTML = titles.join("</br>"); 
     } 
     function init() { 

      displayLocation($g("latitude"), $g("longitude"), $g("city"), $g("region"), $g("country"), $g("country_code")); 
     } 
    </script> 

</head> 
<body onload="init()"> 
    <form id="form1" runat="server"> 
    <div> 
     latitude : <span id="latitude"></span> 
     <br /> 
     longitude : <span id="longitude"></span> 
     <br /> 
     city : <span id="city"></span> 
     <br /> 
     region : <span id="region"></span> 
     <br /> 
     country : <span id="country"></span> 
     <br /> 
     country_code : <span id="country_code"></span> 
     <br /> 
    </div> 
    <input type="text" id="txtSearch" /><input type="button" id="btnSearch" value="get results" 
     onclick="search();" /><br /> 
    &nbsp;<div id="searchResults"> 
    </div> 
    </form> 
</body> 
</html> 

// <copyright file="clientLocation.js" company="Sky Sanders"> 
// This source is placed in the Public Domain. 
// http://skysanders.net/subtext 
// Attribution is appreciated. 
// </copyright> 


/* 
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() { 
    /// <field name="city" type="String" /> 
    /// <field name="region" type="String" /> 
    /// <field name="country" type="String" /> 
    /// <field name="country_code" type="String" /> 
    /// <returns type="ClientLocation.Address"/> 
    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() { 
    /// <field name="latitude" type="Number" /> 
    /// <field name="longitude" type="Number" /> 
    /// <field name="address" type="ClientLocation.Address" /> 
    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; 
    } 

} 


// <copyright file="localSearc.js" company="Sky Sanders"> 
// This source is placed in the Public Domain. 
// http://skysanders.net/subtext 
// Attribution is appreciated. 
// </copyright> 
/* 
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() { 
    /// <field name="type" type="String"/> 
    /// <field name="number" type="String"/> 
    /// <returns type="LocalSearch.PhoneNumber"/> 

    if (arguments.length > 0) { 
     this.type = arguments[0].type; 
     this.number = arguments[0].number; 
    } 
    else { 
     this.type = ""; 
     this.number = ""; 
    } 
} 



LocalSearch.Result = function() { 
    /// <field name="GsearchResultClass" type="String"/> 
    /// <field name="viewportmode" type="String"/> 
    /// <field name="listingType" type="String"/> 
    /// <field name="lat" type="String"/> 
    /// <field name="lng" type="String"/> 
    /// <field name="accuracy" type="String"/> 
    /// <field name="title" type="String"/> 
    /// <field name="titleNoFormatting" type="String"/> 
    /// <field name="ddUrl" type="String"/> 
    /// <field name="ddUrlToHere" type="String"/> 
    /// <field name="ddUrlFromHere" type="String"/> 
    /// <field name="streetAddress" type="String"/> 
    /// <field name="city" type="String"/> 
    /// <field name="region" type="String"/> 
    /// <field name="country" type="String"/> 
    /// <field name="staticMapUrl" type="String"/> 
    /// <field name="url" type="String"/> 
    /// <field name="content" type="String"/> 
    /// <field name="maxAge" type="Number"/> 
    /// <field name="phoneNumbers" type="Array"/> 
    /// <field name="addressLines" type="Array"/> 
    // <returns type="LocalSearch.Result"/> 
    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 = []; 
    } 


} 
+1

के साथ कुछ बनाने में नफरत है उदाहरण कोड के लिए धन्यवाद सैंडर्स मैं मूल रूप से ऐसे तरीके की तलाश कर रहा था जहां उपयोगकर्ता व्यवसाय का नाम और शहर निर्दिष्ट करता है - और उस जानकारी का उपयोग करके मैं Google कोड का उपयोग करके पता खींच सकता हूं। रोलैंड ने मुझे इस लिंक के साथ प्रदान किया जो वास्तव में करता है: http://code.google.com/apis/ajax/playground/#center_localsearch लेकिन मेरी चिंता यह है कि क्या मैं उस जानकारी का उपयोग कर सकता हूं और इसे अपने डेटाबेस – Gublooo

+1

हाँ में संग्रहीत कर सकता हूं , मैं बस एक सरल जेसनपी रणनीति के साथ GLocalSearch से खींचने का एक नमूना खत्म कर रहा था। स्टोरेज के लिए, और इस नमूने के उपयोग के लिए, आपको Google एपीआई पेज पर पोस्ट की गई उपयोग की शर्तों की जांच करनी होगी। मैंने अन्य लोगों के लिए नमूना पोस्ट किया जो इस प्रकार की चीज़ की तलाश में आते हैं –

+1

आपको Google लाइसेंस की जांच करने की आवश्यकता है। मुझे विश्वास नहीं है कि आप पुनः उपयोग/भंडारण के लिए अपने डेटा को "साफ़" कर सकते हैं। हमारे मानचित्र साजिश के लिए हमें उनके साथ व्यापार लाइसेंस जाना पड़ा। इसके अलावा आप मुफ्त संस्करणों पर कॉल की संख्या पर सीमित हैं, लेकिन इससे आपको प्रभावित नहीं हो सकता है। – KeyOfJ

2

आप केवल रेस्तरां ऊपर देख रहे हैं, Yelp के एपीआई का उपयोग कर प्रयास करें। आप एक खोज त्रिज्या के भीतर अपने नाम से एक व्यवसाय की खोज कर सकते हैं। Google की तुलना में उनका एपीआई भी उपयोग करना आसान और आसान है।

http://www.yelp.com/developers/documentation/search_api

संबंधित मुद्दे