Is it possible to add personal sites to google maps v3 autocomplete?

6

I wanted to use the google address search but also wanted to introduce some personal areas. In div that is generated by google I can add the fields I want, but I can not create a function in click because there must be something in google api that blocks click . Here is the code I used to add to the search:

   $(".pac-container").append('<div id="areasearch' + e + '" class="pac-item areasearch" style="display:none" onclick="clickOneAreaLocalizar(\'' + $(this).text() + '\')"><span class="pac-icon pac-icon-areas"></span><span class="pac-item-query"><span class="pac-matched"></span>' + $(this).text() + '</span> <span>Area</span></div>');

Result:

Hereisthecodetoaddthesearchtotheinput:

varinput=/**@type{HTMLInputElement}*/(document.getElementById('TextBoxPesquisaMaps'));varsearchBox=newgoogle.maps.places.Autocomplete(/**@type{HTMLInputElement}*/(input),{types:['geocode']});//Listenfortheeventfiredwhentheuserselectsanitemfromthe//picklist.Retrievethematchingplacesforthatitem.google.maps.event.addListener(searchBox,'place_changed',function(){varplaces=searchBox.getPlace();//Foreachplace,gettheicon,placename,andlocation.varbounds=newgoogle.maps.LatLngBounds();bounds.extend(places.geometry.location);localizarMaisProximo(places.geometry.location);map.fitBounds(bounds);});

Imadethisexampletounderstandbetter. jsfiddle when you load qwerty it makes an alert.

Does anyone have any idea how to do this? Thank you.

    
asked by anonymous 26.11.2014 / 16:33

1 answer

1

What you want is called custom markers, You must create the bookmarks and add them to the map, this way they will appear in the search box too!

See the links below:

10.01.2017 / 22:51