Last active
August 29, 2015 14:01
-
-
Save pokonski/2af21bb203d19a050a71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div style='width: 800px;'> | |
<div id="map" style='width: 800px; height: 400px;'></div> | |
</div> | |
<script type="text/javascript"> | |
function displayOnMap(position){ | |
var marker = handler.addMarker({ | |
lat: position.coords.latitude, | |
lng: position.coords.longitude | |
}); | |
handler.map.centerOn(marker); | |
}; | |
handler = Gmaps.build('Google'); | |
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){ | |
if(navigator.geolocation) | |
navigator.geolocation.getCurrentPosition(displayOnMap); | |
handler.addMarkers(<%= raw @points.to_json %>); | |
}); | |
//aktualizacja 4 | |
google.maps.event.addListener(handler.getMap(), 'click', function(event){ | |
var marker = handler.addMarker({ | |
lat: event.latLng.lat(), | |
lng: event.latLng.lng() | |
}); | |
$.ajax({ | |
url: '<%= points_path %>', | |
method: 'post', | |
data: { | |
point: { | |
latitude: event.latLng.lat(), | |
longitude: event.latLng.lng(), | |
route_id: <%= @route.id %>, | |
} | |
} | |
}); | |
}); | |
// koniec aktualizacja | |
//aktualizacja 3 | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lat: 51.02482312853735 | |
lng: 17.14691162109375 | |
lat: 51.06108759210944 | |
lng: 17.244415283203125 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def edit | |
@points = Gmaps4rails.build_markers(@route.points) do |point, marker| | |
marker.lat point.latitude | |
marker.lng point.longitude | |
end | |
end |
Author
pokonski
commented
May 25, 2014
<script src="//maps.google.com/maps/api/js?v=3.13&sensor=false&libraries=geometry" type="text/javascript"></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js' type='text/javascript'></script>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment