gmaps4rails gem を使用して、Rails アプリでマップを表示します。ユーザーが位置、範囲内、および半径タイプを入力できる部分があります。
例:
location => Chicago, IL,
within => 10,
radius type => km(kilometer).
ユーザーが「レビューの更新」リンクをクリックしたときに、円のマーカーと半径を更新したい。以下の構文を使用して、マーカーを既に置き換えました。
function add_marker(location_served) {
var location = $(location_served).val();
var geocoder;
geocoder = new google.maps.Geocoder();
geocoder.geocode( {
'address': location
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
Gmaps4Rails.replace_markers([{
"description": "",
"title": "",
"longitude": results[0].geometry.location.lng(),
"latitude": results[0].geometry.location.lat(),
"picture": "",
"width": "",
"height": ""
}]);
} else {
alert("The location you've entered is invalid");
}
});
}
しかし、円の半径を更新する方法がわかりません。にcreate_circle
メソッドが表示されgmaps4rails.js
ていますが、そのメソッドを使用するときに渡すべきパラメーターがわかりません。
サークルを動的に更新する方法を知っている人はいますか?
ありがとう