Вопрос

I have Markers setup with gmaps4rails.

Now I want to implement a classic search function.

If I find one object, it should directly show the marker.infowindow

How do I open it directly?

I tried:

function focusSearch() {
            handler.map.centerOn({ lat: <%=@searchy.latitude %>, lng: <%=@searchy.longitude %>});
            handler.getMap().setZoom(16);
            marker = <%=@searchy.id%>
            marker.infowindow.open(map, marker.serviceObject);
      }

But I guess I am going wrong there... Anyone can help?

If you have an Idea how to directly use the #search:params, I am happy!

Thanks for helping out!

Это было полезно?

Решение

I've created a plunkr with working code here.

Basically steps are:

  • associate the marker to the original json data where ids are available

  • search the marker list for the id you expect

  • trigger the 'click' google map event on the marker which triggers pan + infowindow

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top