Skip to content

Commit

Permalink
Merge pull request #78 from ArnoldV/develop
Browse files Browse the repository at this point in the history
Release 2.0.3 with fixes for map rendering and events
  • Loading branch information
robertjf authored Dec 20, 2021
2 parents 0575ff3 + 07c9728 commit ec8c3f9
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Our.Umbraco.GMaps.Core/Our.Umbraco.GMaps.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net5.0;net472</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>

<Version>2.0.3-pre003</Version>
<Version>2.0.3</Version>
<Authors>Arnold Visser</Authors>
<Company>Arnold Visser</Company>
<Description>Basic Google Maps with autocomplete property editor for Umbraco 8+. This package contains the Core DLL only.</Description>
Expand Down
18 changes: 15 additions & 3 deletions Our.Umbraco.GMaps/App_Plugins/Our.Umbraco.GMaps/css/maps.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
.our-coremaps {
.our-coremaps {
position: relative;
max-width: 800px;
}

.our-coremaps__area {
margin-bottom: 20px;
margin-bottom: 1em;
}

.our-coremaps__coordinates {
padding: 0.5em;
/* background-color: #f6f4f4; */
font-size: .8em;
}

.our-coremaps__coordinates span {
min-width: 5em;
font-weight: 600;
display: inline-block;
}

.our-coremaps--loading .our-coremaps__canvas::after {
content: '';
top: 0;
Expand All @@ -19,7 +31,7 @@

.our-coremaps__canvas {
position: relative;
height: 500px;
height: 400px;
width: 100%;
margin-bottom: 20px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element
vm.map = null
vm.mapType = 'roadmap'
vm.mapStyle = {}
vm.mapCenter = ''
vm.address = {}
$scope.mapCenter = ''
$scope.address = {}
vm.mapconfig = {}
vm.marker = null

Expand Down Expand Up @@ -158,17 +158,17 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element

function updateMarkerAddress (address, coordinates) {
actClearLocation.isDisabled = false
vm.address = {}
$scope.address = {}
if (address !== null && (!address.types || address.types.indexOf('plus_code') < 0)) {
const composedAddress = getAddressObject(address.address_components)
vm.address = { ...composedAddress, ...{ full_address: address.formatted_address } }
$scope.address = { ...composedAddress, ...{ full_address: address.formatted_address } }
}
vm.address.coordinates = { lat: coordinates.lat(), lng: coordinates.lng() }
$scope.address.coordinates = { lat: coordinates.lat(), lng: coordinates.lng() }

if (vm.address.full_address) {
$scope.searchedValue = vm.address.full_address
if ($scope.address.full_address) {
$scope.searchedValue = $scope.address.full_address
} else {
$scope.searchedValue = formatCoordinates(vm.address.coordinates)
$scope.searchedValue = formatCoordinates($scope.address.coordinates)
}

saveData()
Expand All @@ -177,7 +177,7 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element
function clearData() {
$scope.model.value = {}
$scope.searchedValue = ''
vm.address = {}
$scope.address = {}
}

function saveData() {
Expand All @@ -188,19 +188,19 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element
vm.mapconfig.zoom = vm.zoomLevel
vm.mapconfig.maptype = vm.mapType

if (vm.mapCenter) {
vm.mapconfig.centerCoordinates = vm.mapCenter
if ($scope.mapCenter) {
vm.mapconfig.centerCoordinates = $scope.mapCenter
}

$scope.model.value = {
address: vm.address,
address: $scope.address,
mapconfig: vm.mapconfig
}
}

function initMapMarker(coordinates) {
if (!coordinates) {
coordinates = vm.address.coordinates
coordinates = $scope.address.coordinates
}

var latLng = new google.maps.LatLng(parseFloat(coordinates.lat), parseFloat(coordinates.lng))
Expand Down Expand Up @@ -279,7 +279,7 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element

google.maps.event.addListener(vm.map, 'center_changed', function () {
var mapCenter = vm.map.getCenter()
vm.mapCenter = { lat: mapCenter.lat(), lng: mapCenter.lng() }
$scope.mapCenter = { lat: mapCenter.lat(), lng: mapCenter.lng() }
saveData()
})

Expand All @@ -296,9 +296,9 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element
// User entered the name of a Place that was not suggested and pressed the Enter key, or the Place Details request failed.
var coordTest = parseCoordinates(vm.searchedValue, false)
if (coordTest) {
vm.address.coordinates = coordTest
$scope.address.coordinates = coordTest
}
initMapMarker(vm.address.coordinates)
initMapMarker($scope.address.coordinates)
return
}

Expand Down Expand Up @@ -337,36 +337,36 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element
}
}

vm.address.coordinates = vm.defaultLocation
$scope.address.coordinates = vm.defaultLocation

// if there is a value on the model set this to the editor
if ($scope.model.value) {

if ($scope.model.value.address) {
actClearLocation.isDisabled = false

vm.address.full_address = $scope.model.value.address.full_address
vm.address.streetNumber = $scope.model.value.address.streetNumber
vm.address.street = $scope.model.value.address.street
vm.address.city = $scope.model.value.address.city
vm.address.state = $scope.model.value.address.state
vm.address.postalcode = $scope.model.value.address.postalcode
vm.address.country = $scope.model.value.address.country
$scope.address.full_address = $scope.model.value.address.full_address
$scope.address.streetNumber = $scope.model.value.address.streetNumber
$scope.address.street = $scope.model.value.address.street
$scope.address.city = $scope.model.value.address.city
$scope.address.state = $scope.model.value.address.state
$scope.address.postalcode = $scope.model.value.address.postalcode
$scope.address.country = $scope.model.value.address.country

var enableSearchedCoordinates = false
if ($scope.model.value.address.coordinates) {
vm.address.coordinates = $scope.model.value.address.coordinates
$scope.address.coordinates = $scope.model.value.address.coordinates
enableSearchedCoordinates = true
} else if (vm.model.value.address.latlng) {
// Fall back to legacy field.
vm.address.coordinates = parseCoordinates($scope.model.value.address.latlng)
$scope.address.coordinates = parseCoordinates($scope.model.value.address.latlng)
enableSearchedCoordinates = true
}

if (vm.address.full_address) {
$scope.searchedValue = vm.address.full_address
if ($scope.address.full_address) {
$scope.searchedValue = $scope.address.full_address
} else if (enableSearchedCoordinates) {
$scope.searchedValue = formatCoordinates(vm.address.coordinates)
$scope.searchedValue = formatCoordinates($scope.address.coordinates)
}
}

Expand All @@ -381,10 +381,10 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element
}

if ($scope.model.value.mapconfig.centerCoordinates) {
vm.mapCenter = $scope.model.value.mapconfig.centerCoordinates
$scope.mapCenter = $scope.model.value.mapconfig.centerCoordinates
} else if ($scope.model.value.mapconfig.mapcenter) {
// Fallback to legacy property
vm.mapCenter = parseCoordinates($scope.model.value.mapconfig.mapcenter)
$scope.mapCenter = parseCoordinates($scope.model.value.mapconfig.mapcenter)
}
}
}
Expand All @@ -393,7 +393,7 @@ angular.module('umbraco').controller('GMapsMapsController', ['$scope', '$element
if (vm.apiKey !== '') {
mapsFactory.initialize(vm.apiKey).then(function () {
// Resolved
initMapMarker(vm.address.coordinates)
initMapMarker($scope.address.coordinates)
$scope.showLoader = false
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

<div class="our-coremaps__area">
<input type="text" class="our-coremaps__autocomplete umb-property-editor umb-textstring textstring" placeholder="Type name, address or geolocation" ng-model="searchedValue" />

<div class="our-coremaps__coordinates">
<span>Pin:</span> <span>{{address.coordinates.lat}},{{address.coordinates.lng}}</span><br />
<span>Center:</span> <span>{{mapCenter.lat}},{{mapCenter.lng}}</span>
</div>
</div>

<div class="our-coremaps__canvas"></div>
Expand Down
2 changes: 1 addition & 1 deletion Our.Umbraco.GMaps/Our.Umbraco.GMaps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<IncludeBuildOutput>false</IncludeBuildOutput>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<Version>2.0.3-pre003</Version>
<Version>2.0.3</Version>
<Authors>Arnold Visser</Authors>
<Company>Arnold Visser</Company>
<Description>Basic Google Maps with autocomplete property editor for Umbraco 8+</Description>
Expand Down

0 comments on commit ec8c3f9

Please sign in to comment.