Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Suggest Text Box #100

Open
gezzeg opened this issue Jan 2, 2017 · 1 comment
Open

Auto Suggest Text Box #100

gezzeg opened this issue Jan 2, 2017 · 1 comment

Comments

@gezzeg
Copy link

gezzeg commented Jan 2, 2017

Hi,

I would like to create auto suggest base on what user key in on a search box.

But i dont know how to get the existing map and markers render by the package.

It seems i need to put the javascript inside the rendered code.

Is there any way i add an event listener inside the rendered code ?

Thank you.


var searchBox = new google.maps.places.SearchBox(document.getElementById('searchmap'));

google.maps.event.addListener(searchBox, 'places_changed', function () {
            var places = searchBox.getPlaces();
            var bounds = new google.maps.LatLngBounds();
            var i, place;
            for (i = 0; place = places[i]; i++) {
                bounds.extend(place.geometry.location);
                marker_0.setPosition(place.geometry.location);
            }
            map.fitBounds(bounds);
            map.setZoom(15);
        });
@bradcornford
Copy link
Owner

Hi there,

They are all accessible via a global 'maps' variable. You can access the current map using 'maps[0].map' and the markers using 'maps[0].markers'.

You can also use an after event to tie any custom javascript to the current map instance as folows:

Mapper::map(53.381128999999990000, -1.470085000000040000, ['eventAfterLoad' => 'console.log("after load");']);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants