2

I have an app with multiple marker in a Rails3 application using gmaps4rails.

The map is loaded initially with all the markers but I have a filter fields on the page which I would like the user to filter different things which are stored in the db for the markers.

How to I trigger the map to call the controller with the parameters which would return a new json object, which I would then put in Gmaps4Rails.replaceMarkers function?

I'm using JQuery so it would probably be best to trigger this behavior from Jquery code.

Regards, Johann

4

1 回答 1

0

为什么不为这些过滤器字段(或在提交按钮中)设置一个事件侦听器,然后通过 AJAX 在服务器上调用 your_controller?

$("#yourSubmitButton").click(function() {
  $.getJSON('/get_markers.json', { filter: "value" }, function(json) {
    Gmaps.map.serviceObject.replaceMarkers(json);
  });
});

没有测试代码。

于 2012-09-25T11:22:51.673 回答