Pregunta

Hi i am showing list of trucks in the map and table view..once i click the truckno in the table view, i want to zoom the particular truck in the map and infowindow of the truck should be open automatically..

I am using https://github.com/apneadiving/Google-Maps-for-Rails

My map construction code

handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%= raw @hash.to_json %>)
handler.bounds.extendWith(markers);
handler.fitMapToBounds();

I can able to view the markers in the map . no issue here.

But markers[0].infowindow.open is not working while clicking the truck# from the table. i found that markers[0].infowindow is null. [Assume that i am clicking the first truck]

Can someone please help to solve this issue. Thanks in advance

¿Fue útil?

Solución

I recommend you have a look at the freshly created example page I've made: http://apneadiving.github.io/

Go to the sidebar section and look at the code, especially:

marker.panTo();
google.maps.event.trigger(marker.getServiceObject(), 'click');

Indeed, infowindow creation is made on click, not before, for perf concerns.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top