Google maps editor
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
define(['app', 'angular'], function (app, angular) {
|
||||
|
||||
angular.module("umbraco")
|
||||
.controller("Umbraco.Editors.GoogleMapsController",
|
||||
function ($rootScope, $scope, notificationsService, dialogService, $log, $timeout) {
|
||||
|
||||
require(
|
||||
[
|
||||
'async!http://maps.google.com/maps/api/js?sensor=false'
|
||||
],
|
||||
function () {
|
||||
|
||||
//Google maps is available and all components are ready to use.
|
||||
//var valueArray = $scope.model.value.split(',');
|
||||
var latLng = new google.maps.LatLng(-34.397, 150.644);
|
||||
|
||||
var mapDiv = document.getElementById($scope.model.alias + '_map');
|
||||
var mapOptions = {
|
||||
zoom: 4,
|
||||
center: latLng,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
var map = new google.maps.Map(mapDiv, mapOptions);
|
||||
|
||||
google.maps.event.addListener(map, 'click', function(event) {
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return angular;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
<div ng-controller="Umbraco.Editors.GoogleMapsController" class="span7">
|
||||
<div class="" style="height: 400px;" id="{{model.alias}}_map"></div>
|
||||
</div>
|
||||
19
src/Umbraco.Web.UI/App_Plugins/GoogleMaps/package.manifest
Normal file
19
src/Umbraco.Web.UI/App_Plugins/GoogleMaps/package.manifest
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
propertyEditors: [
|
||||
{
|
||||
id: "0BA0F832-D759-4526-9B3E-94BBFC98F82E",
|
||||
name: "Google Maps",
|
||||
editor: {
|
||||
view: "~/App_Plugins/GoogleMaps/PropertyEditors/Views/googlemaps.html"
|
||||
}
|
||||
}
|
||||
],
|
||||
config: {
|
||||
paths: {
|
||||
'googleMapsController': '~/App_Plugins/GoogleMaps/PropertyEditors/Js/googlemaps.controller'
|
||||
}
|
||||
},
|
||||
init: [
|
||||
'googleMapsController'
|
||||
]
|
||||
}
|
||||
@@ -4,14 +4,14 @@
|
||||
id: "ec15c1e5-9d90-422a-aa52-4f7622c63bea",
|
||||
name: "Textstring",
|
||||
editor: {
|
||||
view: "~/umbraco/Views/propertyeditors/umbraco/textstring/editor.html"
|
||||
view: "~/umbraco/Views/propertyeditors/umbraco/textstring/editor.html"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "67db8357-ef57-493e-91ac-936d305e0f2a",
|
||||
name: "textarea",
|
||||
name: "Textarea",
|
||||
editor: {
|
||||
view: "~/umbraco/Views/propertyeditors/umbraco/textarea/editor.html"
|
||||
view: "~/umbraco/Views/propertyeditors/umbraco/textarea/editor.html"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -22,7 +22,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "67db8357-ef57-493e-91ac-936d305e0f2a",
|
||||
id: "7e062c13-7c41-4ad9-b389-41d88aeef87c",
|
||||
name: "Content Picker",
|
||||
editor: {
|
||||
view: "~/umbraco/Views/propertyeditors/umbraco/contentpicker/editor.html"
|
||||
|
||||
Reference in New Issue
Block a user