jquery ui - bing maps autocomplete get long and lat from address -


i want user search address , want show som examples , when user chooses 1 examples want find coordinates. can't autocomplete work @ , won't search addresses.

$('[id$=placeofdeparture]:not(.ui-autocomplete-input)').live('focus', function () { $(this).autocomplete({     source: function (request, response) {         $.ajax({             url: "http://dev.virtualearth.net/rest/v1/locations",             datatype: "jsonp",             data: {                 key: 'avmddltsmppoq9n21vldealhnr-h-w-a9hmjxiidn9chbvp5ylleldc_lmnuccrb',                 addressline: request.term,             },             success: function (data) {                 var result = data;             }         });     },     minlength: 2,     select: function (event, ui) {         event.preventdefault();         $(this).val(ui.item.label);         travel = $(this).closest('div').parent();         travel.find('[id$=placeofdeparturecoordinates]').val(ui.item.value);         travel.find('[id$=placeofdeparturecontry]').val(ui.item.countryname);         $(this).change();         updatemap();     },     open: function () {         $(this).removeclass("ui-corner-all").addclass("ui-corner-top");     },     close: function () {         $(this).removeclass("ui-corner-top").addclass("ui-corner-all");     } }); 

});

you can find working code sample of how here: http://www.vivienchevallier.com/articles/use-bing-maps-rest-services-with-jquery-to-build-an-autocomplete-box-and-find-a-location-dynamically

however, highly recommend against doing this. autocomplete generates high volume of transactions against account. if using enterprise account result in high costs. if using non-enterprise account run issues auto complete not work time account rate limited due high frequency of requests.

a better approach create type of functionality looking create user ranked auto suggest. drastically improve suggestions user , make better user experience while minimizing amount of wasteful calls made bing maps service. idea behind user ranked auto suggest create database can store locations selected users. every time user selects location in auto suggest rank value increased , ordering of suggestions based on rank value. if user not find results in auto suggest match query, that's when press search button , call bing maps service return possible results. if select of results add result database. have couple of customers have done , after few months hardly generating transactions against bing maps meant lower costs on long term. meant had lot of insight users looking , locations popular. kind of insight can valuable.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -