From 60611900213189f2087bf4a9b9deea96cc290c11 Mon Sep 17 00:00:00 2001 From: Per Ploug Krogslund Date: Tue, 11 Jun 2013 12:16:31 +0200 Subject: [PATCH 1/2] googlemaps update to support duncanson --- .../googlemaps/googlemaps.controller.js | 52 ++++++++++++++----- src/Umbraco.Web.UI.Client/gruntFile.js | 2 +- .../umbraco/googlemaps/editor.html | 2 +- .../googlemaps/googlemaps.controller.js | 52 ++++++++++++++----- 4 files changed, 82 insertions(+), 26 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/build/belle/views/propertyeditors/umbraco/googlemaps/googlemaps.controller.js b/src/Umbraco.Web.UI.Client/build/belle/views/propertyeditors/umbraco/googlemaps/googlemaps.controller.js index 2570e7f86f..fdde4d2a7e 100644 --- a/src/Umbraco.Web.UI.Client/build/belle/views/propertyeditors/umbraco/googlemaps/googlemaps.controller.js +++ b/src/Umbraco.Web.UI.Client/build/belle/views/propertyeditors/umbraco/googlemaps/googlemaps.controller.js @@ -1,6 +1,6 @@ angular.module("umbraco") .controller("Umbraco.Editors.GoogleMapsController", - function ($rootScope, $scope, notificationsService, $timeout) { + function ($rootScope, $scope, notificationsService, dialogService, $log, $timeout) { require( [ 'async!http://maps.google.com/maps/api/js?sensor=false' @@ -16,27 +16,55 @@ angular.module("umbraco") center: latLng, mapTypeId: google.maps.MapTypeId[$scope.model.config.mapType] }; - + var geocoder = new google.maps.Geocoder(); var map = new google.maps.Map(mapDiv, mapOptions); + var marker = new google.maps.Marker({ map: map, position: latLng, draggable: true }); - - google.maps.event.addListener(marker, "dragend", function(e){ - var newLat = marker.getPosition().lat(); - var newLng = marker.getPosition().lng(); - //here we will set the value - $scope.model.value = newLat + "," + newLng; + google.maps.event.addListener(map, 'click', function(event) { - //call the notication engine - $rootScope.$apply(function () { - notificationsService.warning("Your dragged a marker to", $scope.model.value); - }); + dialogService.mediaPicker({scope: $scope, callback: function(data){ + var image = data.selection[0].src; + + var latLng = event.latLng; + var marker = new google.maps.Marker({ + map: map, + icon: image, + position: latLng, + draggable: true + }); + + google.maps.event.addListener(marker, "dragend", function(e){ + var newLat = marker.getPosition().lat(); + var newLng = marker.getPosition().lng(); + + codeLatLng(marker.getPosition()); + + //set the model value + $scope.model.value = newLat + "," + newLng; + + }); + + }}); }); + + function codeLatLng(latLng) { + geocoder.geocode({'latLng': latLng}, + function(results, status) { + if (status == google.maps.GeocoderStatus.OK) { + var location = results[0].formatted_address; + $rootScope.$apply(function () { + notificationsService.success("Peter just went to: ", location); + }); + } + }); + } + //hack to hook into tab switching for map resizing $('a[data-toggle="tab"]').on('shown', function (e) { google.maps.event.trigger(map, 'resize'); diff --git a/src/Umbraco.Web.UI.Client/gruntFile.js b/src/Umbraco.Web.UI.Client/gruntFile.js index 53e113238f..9acd5611d3 100644 --- a/src/Umbraco.Web.UI.Client/gruntFile.js +++ b/src/Umbraco.Web.UI.Client/gruntFile.js @@ -109,7 +109,7 @@ module.exports = function (grunt) { { dest: '<%= distdir %>/js', src : 'routes.js', expand: true, cwd: 'src/' }] }, media: { - files: [{ dest: 'build/media', src : '*.*', expand: true, cwd: 'legacy_/media/' }] + files: [{ dest: 'build/media', src : '*.*', expand: true, cwd: 'media/' }] }, sampleFiles: { files: [{ dest: '<%= distdir %>/js', src : '*.js', expand: true, cwd: 'src/sample files/' }] diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/umbraco/googlemaps/editor.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/umbraco/googlemaps/editor.html index 0f576c3124..9effacac9e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/umbraco/googlemaps/editor.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/umbraco/googlemaps/editor.html @@ -1,3 +1,3 @@ 
-
+
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/umbraco/googlemaps/googlemaps.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/umbraco/googlemaps/googlemaps.controller.js index 2570e7f86f..fdde4d2a7e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/umbraco/googlemaps/googlemaps.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/umbraco/googlemaps/googlemaps.controller.js @@ -1,6 +1,6 @@ angular.module("umbraco") .controller("Umbraco.Editors.GoogleMapsController", - function ($rootScope, $scope, notificationsService, $timeout) { + function ($rootScope, $scope, notificationsService, dialogService, $log, $timeout) { require( [ 'async!http://maps.google.com/maps/api/js?sensor=false' @@ -16,27 +16,55 @@ angular.module("umbraco") center: latLng, mapTypeId: google.maps.MapTypeId[$scope.model.config.mapType] }; - + var geocoder = new google.maps.Geocoder(); var map = new google.maps.Map(mapDiv, mapOptions); + var marker = new google.maps.Marker({ map: map, position: latLng, draggable: true }); - - google.maps.event.addListener(marker, "dragend", function(e){ - var newLat = marker.getPosition().lat(); - var newLng = marker.getPosition().lng(); - //here we will set the value - $scope.model.value = newLat + "," + newLng; + google.maps.event.addListener(map, 'click', function(event) { - //call the notication engine - $rootScope.$apply(function () { - notificationsService.warning("Your dragged a marker to", $scope.model.value); - }); + dialogService.mediaPicker({scope: $scope, callback: function(data){ + var image = data.selection[0].src; + + var latLng = event.latLng; + var marker = new google.maps.Marker({ + map: map, + icon: image, + position: latLng, + draggable: true + }); + + google.maps.event.addListener(marker, "dragend", function(e){ + var newLat = marker.getPosition().lat(); + var newLng = marker.getPosition().lng(); + + codeLatLng(marker.getPosition()); + + //set the model value + $scope.model.value = newLat + "," + newLng; + + }); + + }}); }); + + function codeLatLng(latLng) { + geocoder.geocode({'latLng': latLng}, + function(results, status) { + if (status == google.maps.GeocoderStatus.OK) { + var location = results[0].formatted_address; + $rootScope.$apply(function () { + notificationsService.success("Peter just went to: ", location); + }); + } + }); + } + //hack to hook into tab switching for map resizing $('a[data-toggle="tab"]').on('shown', function (e) { google.maps.event.trigger(map, 'resize'); From 8810f7d7429940932dfb1cd56ba5c3c3bc89355e Mon Sep 17 00:00:00 2001 From: Per Ploug Krogslund Date: Tue, 11 Jun 2013 12:27:05 +0200 Subject: [PATCH 2/2] gitignore file --- .gitignore | 14 +++++++++++++- src/Umbraco.Web.UI/config/ClientDependency.config | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 339279d0f5..fc519fafa7 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,16 @@ src/packages/repositories.config src/Umbraco.Web.UI/[W]eb.config *.transformed -webpihash.txt \ No newline at end of file +webpihash.txt + +node_modules +src/Umbraco.Web.UI/umbraco/lib/* +src/Umbraco.Web.UI/umbraco/js/umbraco.* +src/Umbraco.Web.UI/umbraco/js/routes.js +src/Umbraco.Web.UI/umbraco/js/main.js +src/Umbraco.Web.UI/umbraco/js/app.js +src/Umbraco.Web.UI/umbraco/Views/**/*.js +src/Umbraco.Web.UI/umbraco/Views/**/*.css +src/Umbraco.Web.UI/umbraco/Views/**/*.html +src/Umbraco.Web.UI/umbraco/assets/* +src/Umbraco.Web.UI.Client/build/* \ No newline at end of file diff --git a/src/Umbraco.Web.UI/config/ClientDependency.config b/src/Umbraco.Web.UI/config/ClientDependency.config index e71cef5626..a168676489 100644 --- a/src/Umbraco.Web.UI/config/ClientDependency.config +++ b/src/Umbraco.Web.UI/config/ClientDependency.config @@ -10,7 +10,7 @@ NOTES: * Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config * A new version will invalidate both client and server cache and create new persisted files --> - +