This repository has been archived by the owner on Nov 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(model-key): model-key comparison on objects
Change model-key to use lodash to compare objects - When objects (outside of coords) are compared via ===, the comparison always returns falls, even if objects are same. Thus, with a false comparison, all markers get marked as needing update, negating doRebuildAll=false. This fixes false negative on comparison. - Add simple examples page with examples controller for issue #1485. - Update model-key spec to include a non-coord comparison on markers Closes #1485
- Loading branch information
Showing
4 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
example/assets/scripts/controllers/issue-1485-doRebuildAll.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
angular.module('testApp', ['uiGmapgoogle-maps']) | ||
.config(['uiGmapGoogleMapApiProvider', function (GoogleMapApiProvider) { | ||
GoogleMapApiProvider.configure({ | ||
// key: 'your api key', | ||
v: '3.17', | ||
libraries: 'weather,geometry,visualization,places' | ||
}); | ||
}]) | ||
.controller('TestController', ['$scope','uiGmapGoogleMapApi', function ($scope,GoogleMapApi) { | ||
|
||
$scope.map = { | ||
center: { | ||
latitude: 33.7550, | ||
longitude: -84.3900 | ||
}, | ||
zoom: 14, | ||
options: { | ||
scrollwheel: false, | ||
panControl: false, | ||
scaleControl: false, | ||
draggable: true, | ||
doRebuildAll: false, | ||
maxZoom: 22, | ||
minZoom: 0 | ||
}, | ||
clusterOptions: { | ||
averageCenter: true, | ||
minimumClusterSize: 10, | ||
zoomOnClick: true | ||
}, | ||
clusterEvents: {}, | ||
refresh : false, | ||
bounds: {}, | ||
events: { | ||
idle: function() { | ||
console.log('idle'); | ||
} | ||
}, | ||
}; | ||
|
||
$scope.addMarker = function(){ | ||
var marker = buildMarker(); | ||
$scope.markers.push(marker); | ||
} | ||
|
||
buildMarker = function(){ | ||
var randomLat = getRandomInt(336550, 338550) / 10000; | ||
var randomLng = getRandomInt(-843900,-843700) / 10000; | ||
return { | ||
id: nextId(), | ||
coords: { | ||
latitude: randomLat, | ||
longitude: randomLng, | ||
}, | ||
options: $scope.markerOptions | ||
} | ||
} | ||
|
||
nextId = function() { | ||
return $scope.markers.length + 1; | ||
} | ||
|
||
getRandomInt = function(min, max) { | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} | ||
|
||
$scope.markers = []; | ||
|
||
GoogleMapApi.then(function(maps) { | ||
console.log('start'); | ||
$scope.maps = maps; | ||
$scope.markerOptions = { | ||
animation: $scope.maps.Animation.DROP, | ||
visible: true | ||
} | ||
$scope.addMarker(); | ||
$scope.addMarker(); | ||
$scope.addMarker(); | ||
$scope.doRebuildAll = false; | ||
}); | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html ng-app="testApp"> | ||
|
||
<head> | ||
<script src="http://maps.googleapis.com/maps/api/js?libraries=visualization&language=en&v=3.13"></script> | ||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script> | ||
<script src="../website_libs/dev_deps.js"></script> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js" type="text/javascript"></script> | ||
<script src="http://cdn.rawgit.com/nmccready/angular-simple-logger/0.0.1/dist/index.js"></script> | ||
<script src="../dist/angular-google-maps.js"></script> | ||
|
||
<link href="assets/stylesheets/example.css" rel="stylesheet" type="text/css"> | ||
</head> | ||
|
||
<body ng-controller="TestController"> | ||
{{sites}} | ||
<ui-gmap-google-map class="col-sm-12 pad-none" center="map.center" zoom="map.zoom" style="min-height: 600px" draggable="true"> | ||
<ui-gmap-markers fit="true" doRebuildAll="doRebuildAll" models="markers" coords="'coords'" options="'options'" clusteroptions="map.clusterOptions"> | ||
</ui-gmap-markers> | ||
</ui-gmap-google-map> | ||
|
||
<button ng-click="addMarker()">Add Marker</button> | ||
</body> | ||
<script src="assets/scripts/controllers/issue-1485-doRebuildAll.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters