etodanik / ion-google-place

Ionic directive for a location dropdown that utilizes google maps
MIT License
250 stars 201 forks source link

Implement Features of ngAutocomplete #3

Open leandroz opened 9 years ago

leandroz commented 9 years ago

Hi Danny!, great work with this directive!

I am using ngAutocomplete (https://github.com/wpalahnuk/ngAutocomplete) in other project and i think that could be great to implement the same features in this directive!

Let me know if you are interested, i could help you if you want!

Congrats!

etodanik commented 9 years ago

Hey Leandro, first of all, thank you! It's always a pleasure to see that someone out there is using this.

What kind of features are you thinking of? I'm definitely interested in improving this directive, but curious to hear your suggestions!

leandroz commented 9 years ago

I think that in first place it would be great to have access to the entire location object outside the readonly input. For example in my case, the user select a location, and then i need the geometry data for that particularly result to be available in the controller scope. Maybe adding other attribute like details is used in ngAutocomplete and bind the entire location object to that attribute. Maybe is better to use the directive as an attribute instead of replacing the entire object. Let me know what you think!

etodanik commented 9 years ago

Well, right now you can set ng-modeland access the full object.

As for making it an attribute, could you give some real use cases? What would be some of the practical use cases for the change? I'm not sure I completely understand what you have in mind.

leandroz commented 9 years ago

It was my mistake, for some reasons the binding to the ng-model was not working but now yes, so i can access to the entire location object perfectly. I think that to be more flexible would be great to:

I thing that with these three features the directive will be awesome.

quipu commented 9 years ago

Hey @leandroz - could you share code on how you're accessing the model object. I, too, am coming from ngAutocomplete, and having trouble triggering a callback from a $watch on the ng-model object in my controller. Perhaps $watch might not be the best way to checking for updated location?

Thanks @israelidanny - I'm really liking this. I notice that I get very different results that I do from Google Places Autocomplete. For my uses, the latter is more useful. Is there someway to get results from your directive that are more similar to what I'd normally get from Autocomplete?

leandroz commented 9 years ago

@quipu i am using the ng-change directive inside the template directive:

<input type="text" readonly="readonly" class="ion-google-place" autocomplete="off" ng-change="centerOnMe()">

So when you choose a location the function is called.

etodanik commented 9 years ago

@quipu - In what way are the results different? The results are straight from the Google API, and technically you should get the same exact results.

@leandroz - The region bias is actually possible to do right now. Just add region biasing to the SDK on load:

<script src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false*&region=es*"></script>

I will however work on adding it with an option to change it dynamically (on a per request basis).

quipu commented 9 years ago

@israelidanny i get something like the following if I search for "Vulc":

Vulcan, AB, Canada
Vulcano, Lipari, Messina, Italy
Vulcania, Saint-Ours, France
Vulcan, Hunedoara County, Romania
Vulcan Way, Richmond, BC, Canada

Whereas, using Autocomplete, I get:

Vulcan Lane, Auckland, New Zealand
Vulcan Lane Cafe, Vulcan Lane, Auckland, New Zealand
Vulcan Chambers, Vulcan Lane, Auckland, New Zealand
Vulcan Steel, Neales Road, Auckland, New Zealand
Vulcan Steel, East Tamaki, Auckland, New Zealand

Looking into it, I think this is due to the API sending different results depending on what API library your using. Autocomplete uses the AutocompleteService from the Places library (https://developers.google.com/maps/documentation/javascript/reference#AutocompleteService) whereas I think you're using the Geocoder (https://developers.google.com/maps/documentation/javascript/reference#Geocoder).

API use is very similar so I was able to get it working for me with only a couple of minor changes.

@leandroz thanks! - ng-change working well for me.

etodanik commented 9 years ago

Would you say that the results from Places are more relevant? If you feel so, I might be interested in a Pull Request for this one! It seems that it loaded things located nearby you.

On Sun, Oct 12, 2014 at 12:47 AM, quipu notifications@github.com wrote:

@israelidanny https://github.com/israelidanny i get something like the following if I search for "Vulc":

Vulcan, AB, Canada Vulcano, Lipari, Messina, Italy Vulcania, Saint-Ours, France Vulcan, Hunedoara County, Romania Vulcan Way, Richmond, BC, Canada

Whereas, using Autocomplete, I get:

Vulcan Lane, Auckland, New Zealand Vulcan Lane Cafe, Vulcan Lane, Auckland, New Zealand Vulcan Chambers, Vulcan Lane, Auckland, New Zealand Vulcan Steel, Neales Road, Auckland, New Zealand Vulcan Steel, East Tamaki, Auckland, New Zealand

Looking into it, I think this is due to the API sending different results depending on what API library your using. Autocomplete uses the AutocompleteService from the Places library ( https://developers.google.com/maps/documentation/javascript/reference#AutocompleteService) whereas I think you're using the Geocoder ( https://developers.google.com/maps/documentation/javascript/reference#Geocoder ).

API use is very similar so I was able to get it working for me with only a couple of minor changes.

@leandroz https://github.com/leandroz thanks! - ng-change working well for me.

— Reply to this email directly or view it on GitHub https://github.com/israelidanny/ion-google-place/issues/3#issuecomment-58765704 .

quipu commented 9 years ago

For the project I'm working on, yes - the audience will generally be searching for locations that are within proximity to their current location. I think introducing the flexibility to configure the API used could be really useful. I'd be happy to work through it and submit a PR.

etodanik commented 9 years ago

That would be great! I'd merge that!

On Sun, Oct 12, 2014 at 1:00 AM, quipu notifications@github.com wrote:

For the project I'm working on, yes - the audience will generally be searching for locations that are within proximity to their current location. I think introducing the flexibility to configure the API used could be really useful. I'd be happy to work through it and submit a PR.

— Reply to this email directly or view it on GitHub https://github.com/israelidanny/ion-google-place/issues/3#issuecomment-58766102 .

svenwoldt commented 9 years ago

How about a more generic version and call it ion-autocomplete or such that works with a multitude of data (resources, promises, data arrays). I am sure you would increase your fan base quite a bit ;-)

etodanik commented 9 years ago

That's an interesting idea! Melikes! Stay tuned in the following days

On Thu, Oct 16, 2014 at 12:11 AM, svenwoldt notifications@github.com wrote:

How about a more generic version and call it ion-autocomplete or such that works with a multitude of data (resources, promises, data arrays). I am sure you would increase your fan base quite a bit ;-)

— Reply to this email directly or view it on GitHub https://github.com/israelidanny/ion-google-place/issues/3#issuecomment-59277147 .

Positivex commented 9 years ago

I would definitly be interested in a version using the Google Places API. The results are more relevant to me.

etodanik commented 9 years ago

@quipu - are you intrested in sharing your changes as a more generic PR?

quipu commented 9 years ago

@israelidanny @Positivex keen to contribute as this is working awesomely for me. I'll try and get something together in the next few days but in the meantime here are my changes to work with Google Places - https://www.diffchecker.com/81x24fiy

I'm also wondering if it would be better for some to adopt an external template - this is something I'll need to do for my use, and possibly a common customization requirement.

Positivex commented 9 years ago

Thanks @quipu ! I implemented your changes and it works like a charm. @israelidanny I created a PR so you can see the changes.

etodanik commented 9 years ago

Hey, all the diff in your PR is absolutely lit up because of differences in tabs. Care to show me where you made the changes?

I'm thinking about the ability to make it support both backends.

quipu commented 9 years ago

Hi Danny. I'll think that would be a great idea. I'll put together some details later today/overnight. FWIW, I've adapted this directive for a number of search uses that hit an API - there might be a way to make it more modular using external templates and API call sub-modules.

matt-ward commented 9 years ago

I think it would be a great improvement to have this directive use the google "places" https://developers.google.com/maps/documentation/javascript/places-autocomplete library, instead of the Geocoding API. The main difference, it looks like, from what I can tell, the ion-google-place directive seems to only work with Addresses, by switching over to "places" it would work with both addresses and locations, like the names of businesses.

quipu commented 9 years ago

Hey @matt-ward - @Positivex and I have a couple of open PRs you can look at to get going with the Places service.

seatechdev commented 8 years ago

Did we ever get the NgAutocomplete integrated into this? Please advise.

manojbsw commented 8 years ago

Hi I wan to use NgAutocomplete with google places. I can see that https://www.diffchecker.com/81x24fiy is expired now. Can anyone please share the difference/ or the code snippet. Thanks

harmoney-grege commented 8 years ago

Hey @manojbsw - https://github.com/israelidanny/ion-google-place/pull/5/files pretty much covers it.