Answer the question
In order to leave comments, you need to log in
Gmaps4rails - how to bind points to the road?
Hello
In the application I use the Gmaps4rails gem to display routes on the map. At the moment I just draw markers on the map and connect them with lines. The points are very scattered (GPS errors), so I want to tie them to the nearest road like here:
stackoverflow.com/questions/10513360/polyline-snap...
or here:
econym.org.uk/gmap/example_snappath.htm
Code:
<div class="map_container" style='width: 800px; height: 500px;'>
<div id="map" style='width: 800px; height: 500px;'></div>
</div>
<script type="text/javascript">
jQuery(document).ready(function() {
handler = Gmaps.build('Google', { markers: { maxRandomDistance: null } });
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%=raw @markers.to_json %>);
polyline = handler.addPolylines(<%=raw @polyline.to_json %>, { "strokeColor" : "#0088cc" });
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
});
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question