2011-12-30 5 views
1

こんにちは私は私のウェブサイトでBingマップを使用しています。私の質問は私のウェブサイトにどのように私はピンコードを使用して領域の緯度を長く得ることができますです。エリアピンコードを与えることでlong latをクエリするために使用できるAPIはありますか?私はバックエンドでそれをやりたいその特定のWeb APIにいくつかのajax呼び出しを使用して、lat langを取得し、データベースに保存して、そのlong latを私のbingマップ上の場所をプロットするのに使うことができます。ピンコードを使用して特定のエリアの緯度、経度を見つける方法

私はjingオブジェクトにlong long値を入れてBingマップに渡す必要があるbingマップ7を使用しています。

function GetMap() 
{ 
var mapOptions = { 
credentials: "Your Bing Maps Key", 
center: new Microsoft.Maps.Location(47.592, -122.332), // i want these value in my   database 
mapTypeId: Microsoft.Maps.MapTypeId.birdseye, 
zoom: 17, 
showScalebar: false 
} 
var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), mapOptions); 
} 

私はハード、それをコーディングすることができますが、私のアプリケーションでは、私は、クライアントが任意の新しい場所を追加するとき、私はそれが好きたいバックエンドのように、新しい場所を追加するために使用されるオプションは、それが自動的にもその緯度長期保存し、クライアントを与えています。

http://www.geonames.org/export/ws-overview.html

はあなたがルックアップするために1を使用することができます。

おかげ

+0

私はGoogleのapiを使用してそれは素晴らしいbtを動作させる私はあなたがGoogleベースのソリューションをしたいとは思わない。あなたはbing apiで作業しているからです。私はそれを共有することができますGoogleベースのコードをしたい場合... – aProgrammer

+0

あなたはそれを共有してください。ピンコードからlong longを見つけるために、他のいくつかのAPIやWebサービスを使用していますか? – ifti

+0

これを試すことができますhttp://lab.iamrohit.in/pincode_finder/ – inrsaurabh

答えて

1

AT、長い値は、最善の解決策ではないかもしれませんまだnot a standard世界一周。たとえば、米国のピンコード(郵便番号)は通常5桁(つまり06160)で、私の世界では通常6桁以上です。

住所、州、国の組み合わせを使用できます世界のほぼすべての地域でほぼ正確な地理座標を見つけるためのピンコード。私はGPLの下でコミュニティにこのコードを寄付することで...ここで、ロング値緯度を見つけるためのGoogleのAPIを呼び出すスクリプトは、以下を参照してください: -

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"> </script> 

<script src="http://maps.google.com/maps?file=api&v=3&key=ABQIAAAA7j_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"> </script> 
<script type="text/javascript"> 

     var geocoder, location1; 

     function initialize() { 
      geocoder = new GClientGeocoder(); 
     } 
     function prepareQuery(){ 
      var query=''; 
      var a1 = document.getElementById('address1').value; 
      var a2 = document.getElementById('address2').value; 
      var a3 = document.getElementById('address3').value; 
      var cty = document.getElementById('city').value; 
      var stat = document.getElementById('state').value; 
      var cntry =document.getElementById('country').value; 
      var pin = document.getElementById('pincode').value; 

      if(a1 != null && a1!=''){ 
       query = query + a1 + ",";      
      } 
      if(a2 != null && a2!=''){ 
       query =query + a2 + ",";      
      } 
      if(a3 != null && a3!=''){ 
       query = query + a3 + ",";      
      } 
      if(cty != null && cty!=''){ 
       query = query + cty + ",";      
      } 
      if(stat != null && stat!=''){ 
       query = query + stat + ",";      
      } 
      if(cntry != null && cntry!=''){ 
       query = query + cntry + ",";      
      } 
      if(pin != null && pin!=''){ 
       query = query + pin + ",";      
      } 
      //    alert("Prepare Query Returns " +query); 
      return query; 
     } 
     function submitFunc(){ 
      var location = prepareQuery();    
      geocoder.getLocations(location, function (response) { 
       if (!response || response.Status.code != 200) 
       { 
        alert("Sorry, we were unable to geocode the address"); 
       } 
       else 
       {      
        location1 = {latitude: response.Placemark[0].Point.coordinates[1], longitude: response.Placemark[0].Point.coordinates[0], Address : response.Placemark[0].address}; 

        var items = []; 
        $.each(location1, function(key, value){       
         items.push('<li id="' + key + '">' + key +" : "+ value + '</li>'); 
        }); 
        //      alert(items) 
        $("body").append("Results is :-"); 
        $('<ul/>', { 
         'class': 'my-new-list', 
         html: items.join('') 
        }).appendTo('body'); 
       } 
      }); 
     } 

    </script> 

とhtmlがどのように見える....

 Line 1 : <input type="text" id="address1" value="" placeholder="Enter first line of address."/> <br></br>    
     Line 2 :<input type="text" id="address2" value="" placeholder="Enter second line of address."/> <br></br>    
     Line 3 :<input type="text" id="address3" value="" placeholder="Enter third line of address."/> <br></br>    
     City  : <input type="text" id="city" value="" placeholder="Enter city name."/> <br></br>    
     State : <input type="text" id="state" value="" placeholder="Enter state name."/> <br></br>    
     Country : <input type="text" id="country" value="" placeholder="Enter country name."/> <br></br>    
     Pin Code : <input type="text" id="pincode" value="" placeholder="Enter pincode value."/> <br></br>    
     <input type="button" name="submitBtn" value="submit" onclick='submitFunc();'/> <br></br> 

     <h3> <strong> Your Results Will be displayed Here . . . .</strong> </h3> 
+0

おかげで素晴らしい助けて。 – ifti

1

Geonamesは、ロケーションもののすべての種類の良いサービスで、彼らが提供するサービスのリストを見てみましょう郵便番号?一世紀以上に人気ものの、ピンコードであるためapi.geonames.org/postalCodeLookupJSON?postalcode=6600 &国は=緯度を取得するためのPINコードの使用を&名=デモ

+0

助けてくれてありがとうございますが、私はそこに任意のAPIまたはサンプルコードを取得していません。あなたは何かチュートリアルを得ることができるいくつかのコードや他のリンクを共有してください ありがとう – ifti

+0

私はこのリンクを使用しましたapi.geonames.org/postalCodeLookupJSON?postalcode=6600&country=AT&username=demoしかし、それは私のために働いていません – ifti

関連する問題