angular-ui / angular-google-maps

AngularJS directives for the Google Maps Javascript API
http://angular-ui.github.io/angular-google-maps
2.52k stars 1.07k forks source link

Is it possible to use the autocomplete option in an input field without the map #1828

Open flyingboy007 opened 8 years ago

flyingboy007 commented 8 years ago

I have a search field that wont use the map.

html <input type="text" ui-gmap-search-box ng-model="GeneralFactory.Location" events="searchbox.events" placeholder="Location" class="form-control input-lg">

app.js

app.config(['uiGmapGoogleMapApiProvider', function (GoogleMapApi) {
    GoogleMapApi.configure({
        //  key: 'your api key',
        //    v: '3.20',
        libraries: 'places'
    });
}]);

app.controller('mainCtrl', ['$scope', '$log', 'uiGmapGoogleMapApi', function ($scope, $log, GoogleMapApi) {
    angular.extend($scope, {
        searchbox: {
            events:{
                places_changed: function (searchBox) {}
            }
        },
        options: {
            scrollwheel: false
        }
    });

    GoogleMapApi.then(function(maps) {
        maps.visualRefresh = true;
    });
}]);

All I want is an autocompletion of location. But this throws following error

Error: [$compile:ctreq] Controller 'uiGmapGoogleMap', required by directive 'uiGmapSearchBox', can't be found!

I think this is because I havent put searchbox inside the map. As I dont want to use the map what can I do here?

mahmoudmy commented 8 years ago

This is my question too! +1

jayeshanandani commented 8 years ago

I believe you can create the custom directive for that. I just did that. Used SDK from Google API in config and then made a directive for location autocomplete.

flyingboy007 commented 8 years ago

@jayeshanandani yes thats possible and instead of creating it myself I used ngautocomplete..But thought this have it built in..

nickpricks commented 8 years ago

Why don't you @flyingboy007 try using the places library http://maps.googleapis.com/maps/api/js?libraries=places

More info https://developers.google.com/maps/documentation/javascript/places

kandizzy commented 8 years ago

This has been asked a few times before, but it is not currently supported. If anyone wants to take this on that would great! It is unlikely the current team will be able to add this capability any time soon.