Artem Shoobovych avatar Artem Shoobovych committed 6b25f6d

Finished routing functionality

Comments (0)

Files changed (3)

Add a comment to this file

app/assets/images/drag_hand.png

Added
New image

app/assets/stylesheets/map.css.scss

 	display: none;
 }
 
-.markerList .markerListEntry .actions {
-	display: inline;
-	vertical-align: middle;
-	box-shadow: none;
+.markerListEntry {
+    border-radius: 10px 10px 10px 10px;
+    padding: 10px;
+    vertical-align: middle;
+    padding-left: 20px;
+    
+	.actions {
+		display: inline;
+		vertical-align: middle;
+		box-shadow: none;
+
+		* {
+			margin-left: 5px;
+		}
+	}
+}
+
+	.markerListEntry:hover {
+	background-color: #FFD77D;
+	cursor: url('/assets/drag_hand.png'), default;
 }
 
-.markerList .markerListEntry .actions * {
-	margin-left: 5px;
+.markerListEntry {
 }

app/views/map/_actions.html.slim

 javascript:
-	Array.prototype.swap = function(a, b) { 
-        var tmp = this.slice(a, a + 1)[0];
-
-        this[a] = this[b];
-        this[b] = tmp;
-
-        return this;
-    }
-
 	$(document).ready(function() {
 		var sortableConstructorOptions = {
 			beforeStop: function(evt, ui) {
 				markerId = parseInt(block.attr('markerId'));
 
 			for (var i = markerId + 1; i < window.map.routingMarkers.length; i++) {
-				$('[markerId=' + i + ']').attr('markerId', i - 1);
+				$('[markerId = ' + i + ']').attr('markerId', i - 1);
 			}
 
 			window.map.removeMarker(window.map.routingMarkers[markerId]);
 					}
 				);
 
-				var markerId = window.map.routingMarkers.length - 1;
+				var markerId = window.map.routingMarkers.length - 1,
+					markerEntryInput = markerEntry.children('input');
+
+				window.map.routingMarkers[markerId].on('drag', function() {
+					$('[markerId = ' + markerId + '] input').val(marker.getLatLng().lat + '; ' + marker.getLatLng().lng);
+				});
+
+				var updateInputText = function() {
+					window.map.geocoder.geocode({'latLng': window.map.lToGoogleLatLng(marker.getLatLng())}, function(results, status) {
+						if (status == google.maps.GeocoderStatus.OK) {
+							if (results[1]) {
+								$('[markerId = ' + markerId + '] input').val(results[1].formatted_address);
+							}
+						}
+					});
+				}
+
+				updateInputText();
+
+				window.map.routingMarkers[markerId].on('dragend', function() {
+					updateInputText();
+				});
+
+				/*markerEntryInput.live('keydown', function(char) {
+					console.log(char);
+
+					if (false) {
+						window.map.geocoder.geocode({'address': markerEntryInput.val()}, function(results, status) {
+							if (status == google.maps.GeocoderStatus.OK) {
+								if (results[1]) {
+									console.log('found', results);
+								}
+							}
+						});
+					}
+				});*/
+
 				markerEntry.attr('markerId', markerId);
-				markerEntry.children('input').val(marker.getLatLng().lat + "; " + marker.getLatLng().lng);
+				markerEntryInput.val(marker.getLatLng().lat + "; " + marker.getLatLng().lng);
 				markerEntry.appendTo($('#routingPanel'));
 
 				if (window.map.routingMarkers.length > 1) {
 
 #tabsRouting class="{ title: '#{ t('panel.routes') }' } extruder"
 	.steps
-		span
-			= t('feature_disabled')
+		/span
+			/= t('feature_disabled')
 		
 		/p
 			/label for="leaveDate" = t('panel.leaveDate')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.