Gmaps4Rails画圆相对于一个动态点

问题描述 投票:1回答:1

这可能是一个JavaScript的问题,而是因为它也使用Rails变量优惠和gmpas4rails宝石,我想问一下你啦...

我有这个在我看来,

<%= gmaps(
    { 
     "markers"     => { "data" => @json },

     "circles"     => { "data" => '[
                         {"lng": 122.214897, "lat": 37.772323, "radius": 25000, "strokeColor": "#FF0000"}
                         ]',
                      },
    }
        ) %>

而且在那里我有圆圈的部分我想有这

"circles"     => { "data" => '[
                         {"lng": '@shop.longitude', "lat": '@shop.latitude', "radius": 25000, "strokeColor": "#FF0000"}

因此,对于每家店铺将在中心圆和绘制区...

javascript ruby-on-rails gmaps4rails
1个回答
1
投票

你不应该逃避的纬度和经度:

"circles" => { 
  "data" => "[{'lng': #{@shop.longitude}, 'lat': #{@shop.latitude}, 'radius': 25000, 'strokeColor': '#FF0000'}]"
}

另一种解决方案:

"circles" => { 
  "data" => [{'lng' => @shop.longitude, 'lat' => @shop.latitude, 'radius' => 25000, 'strokeColor' => '#FF0000'}].to_json
}
© www.soinside.com 2019 - 2024. All rights reserved.