1

When I pass a lat and lng coordinate to geocomplete how do I prevent it from displaying the street portion of the address:

When I pass these coordinates to geocomplete:

var lat = '40.7127744'
var lng = '-74.006059';

var lat_and_long = lat + ', ' + lng ;
$("#location").geocomplete("find", lat_and_long);

it returns:

New York City Hall, City Hall Park, New York, NY 10007, USA

How do I restrict it to:

New York, NY, United States
John Slegers
  • 45,213
  • 22
  • 199
  • 169
Paul
  • 11,671
  • 32
  • 91
  • 143
  • Do you have a reason to believe that this is possible? What reason do you have for wanting *less* information than is available? It is clearly simple to ignore the parts of the returned string that don't interest you. Are you hoping that asking for less accurate data will be faster, or is it a privacy issue that worries you? – Borodin Mar 20 '15 at 01:12
  • Privacy concerns...when using geocomplete to enter a location it displays just the city and state but when looking up an address based on lat/lng it returns much more. – Paul Mar 20 '15 at 11:04

1 Answers1

0

I do not think you have setting for that...

but since it return a string.... I think this should do it.

str.replace(/.*,([^,]*,[^0-9,]*)[0-9]*([^,]*,[^,]*)/g, "$1$2")
kaho
  • 4,746
  • 1
  • 16
  • 24