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'); 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 --> - +