我正在将Gmaps Heatmap与ruby集成在轨道上我可以在其上绘制我的数据,但无法在任何弹出框中显示纬度,经度和位置信息。以下是我的控制器中的一个方法,我在route.rb
中定义了它def plot_map
@records = Place.where("keyword_id = ?",params[:place_keyword_id]).order("created_at desc")
@places = Gmaps4rails.build_markers(@records) do |user, marker|
marker.lat user.latitude
marker.lng user.longitude
end
我有一个视图plot_map.html.erb
<script>
$(document).ready(function() {
var myLatlng = new google.maps.LatLng(25.6586, -80.3568);
// map options,
var myOptions = {
zoom: 3,
center: myLatlng
};
// standard map
map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
// heatmap layer
heatmap = new HeatmapOverlay(map,
{
// radius should be small ONLY if scaleRadius is true (or small radius is intended)
"radius": 2,
"maxOpacity": 1,
// scales the radius based on map zoom
"scaleRadius": true,
// if set to false the heatmap uses the global maximum for colorization
// if activated: uses the data maximum within the current map boundaries
// (there will always be a red spot with useLocalExtremas true)
"useLocalExtrema": true,
// which field name in your data represents the latitude - default "lat"
latField: 'lat',
// which field name in your data represents the longitude - default "lng"
lngField: 'lng',
// which field name in your data represents the data value - default "value"
valueField: 'count'
}
);
var testData = {
max: 8,
data:<%= raw @places.to_json%>
};
heatmap.setData(testData);
});
当我们点击加热部分时。我们可以在任何像popowindow这样的popbox中显示纬度,经度吗?