gmaps4rails gemを使ってマップを自分のアプリに表示します。ユーザーが場所、半径、半径タイプを入力できる部分があります。gmaps4rails gemを使用してradius circleをリフレッシュするにはどうすればよいですか?
例:
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");
}
});
}
しかし、円の半径を更新する方法についてはわかりません。 gmaps4rails.js
にはcreate_circle
メソッドがありますが、そのメソッドを使用するときに渡すべきパラメータはわかりません。
サークルを動的に更新する方法を知っている人はいますか?
おかげ
あなたの答えをありがとう。 'Gmaps4Rails.circles = [{"latitude":-122.214897、 "経度":-122.214897、 "radius":10000}]を追加します。 Gmaps4Rails.create_circles(); '円はありません、参考、私はバージョン0.7.6を使用しています。あなたの次の答えをありがとう – fatimah
奇妙なことに、既に存在しています。https://github.com/apneadiving/Google-Maps-for-Rails/blob/v0.7.6/public/javascripts/gmaps4rails.jsよくあることは何ですか? – apneadiving
ええと、エラーメッセージはありません。しかし、サークルは現れなかった。 – fatimah