Markers and Windows(Angular google maps) not working after upgrade to angular 1.3.8 - angularjs

I have been using angular-google-maps for sometime. I have not faced any major issues till now. But one of my colleagues had upgraded angular to 1.3.8 recently. And since then I am getting the following errors while instantiating the and directives and I do not see any markers. Here are the errors I get. Any inputs or directions to debug will be awesome. Thanks in advance.
Here is the first error:
Error: this.mapCtrl.getMap is not a function
this.MarkersParentModel</MarkersParentModel.prototype.createMarkers#http://localhost/scripts/1b3f05c4.modules.js:2637:75
__bind/<#http://localhost/scripts/1b3f05c4.modules.js:2569:16
this.MarkersParentModel</MarkersParentModel.prototype.onTimeOut#http://localhost/scripts/1b3f05c4.modules.js:2612:16
__bind/<#http://localhost/scripts/1b3f05c4.modules.js:2569:16
__bind/<#http://localhost/scripts/1b3f05c4.modules.js:2234:16
IMarkerParentModel/<#http://localhost/scripts/1b3f05c4.modules.js:2290:11
timeout/timeoutId<#http://localhost/bower_components/angular/angular.js:16205:28
completeOutstandingRequest#http://localhost/bower_components/angular/angular.js:4902:7
Browser/self.defer/timeoutId<#http://localhost/bower_components/angular/angular.js:5282:7
http://localhost/bower_components/angular/angular.js
Line 11594
And here is the second error:
Error: this.linked.ctrls[0].getMap is not a function
this.WindowsParentModel</WindowsParentModel.prototype.createChildScopesWindows#http://localhost/scripts/1b3f05c4.modules.js:2860:21
__bind/<#http://localhost/scripts/1b3f05c4.modules.js:2726:16
WindowsParentModel/<#http://localhost/scripts/1b3f05c4.modules.js:2785:18
timeout/timeoutId<#http://localhost/bower_components/angular/angular.js:16205:28
completeOutstandingRequest#http://localhost/bower_components/angular/angular.js:4902:7
Browser/self.defer/timeoutId<#http://localhost/bower_components/angular/angular.js:5282:7
http://localhost/bower_components/angular/angular.js
Line 11594
Line 2860:
var markersScope, modelsNotDefined, _this = this;
this.isIconVisibleOnClick = true;
if (angular.isDefined(this.linked.attrs.isiconvisibleonclick)) {
this.isIconVisibleOnClick = this.linked.scope.isIconVisibleOnClick;
}
>>>> this.gMap = this.linked.ctrls[0].getMap();
markersScope = this.linked.ctrls.length > 1 && this.linked.ctrls[1] != null ? this.linked.ctrls[1].getMarkersScope() : void 0;
modelsNotDefined = angular.isUndefined(this.linked.scope.models);
if (modelsNotDefined && (markersScope === void 0 || markersScope.markerModels === void 0 && markersScope.models === void 0)) {
this.$log.info('No models to create windows from! Need direct models or models derrived from markers!');
return;
}
Line 2637:
this.gMarkerManager = new directives.api.managers.MarkerManager(this.mapCtrl.getMap());

Related

Strange IE11 behavior with "Object doesn't support property or method 'includes'"

I have some trouble with my project in IE11 (It's react project, I use create-react-app prod build). It works fine in other browsers and in IE11 too, except if I click precise link to one route in IE11 (other routes work), it throws an error "Object doesn't support property or method 'includes'". I added 'babel-polyfill' but problem still exists, but if I, for example, not just load page, but reload it then too and then click that link, or when I load directly that link page it works fine.
I don't use 'includes' in my code, suppose it is used in some library, among those I use.
May be someone know, why it not work properly after loading page and after reloading only.
Thanks for help.
It appears to be handled separately from the rest of babel through this plugin.
includes is a Javascript function that determines whether an item exists in an array, and it is not available in Internet Explorer. See docs/chart below. (Apparently it isn't part of babel by default because of some difficulty identifying whether a variable is an array. There are issues around this going back 2+ years in the babel repos.)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
Part of the browser compatibility chart from those docs:
McGuireV10's answer is great if you can control your javascript compilation process, however including a shim might be faster.
In my create-react-app project using react-select v2 i was hitting a few of these errors, and so included air-bnb's bundle:
yarn add airbnb-js-shims
and then added this single line to my code:
import 'airbnb-js-shims';
good luck!
Add below function in top of the all imports.
if (!Array.prototype.includes) {
Object.defineProperty(Array.prototype, 'includes', {
value: function (searchElement, fromIndex) {
if (this == null) {
throw new TypeError('"this" is null or not defined');
}
// 1. Let O be ? ToObject(this value).
var o = Object(this);
// 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0;
// 3. If len is 0, return false.
if (len === 0) {
return false;
}
// 4. Let n be ? ToInteger(fromIndex).
// (If fromIndex is undefined, this step produces the value 0.)
var n = fromIndex | 0;
// 5. If n ≥ 0, then
// a. Let k be n.
// 6. Else n < 0,
// a. Let k be len + n.
// b. If k < 0, let k be 0.
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
function sameValueZero(x, y) {
return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y));
}
// 7. Repeat, while k < len
while (k < len) {
// a. Let elementK be the result of ? Get(O, ! ToString(k)).
// b. If SameValueZero(searchElement, elementK) is true, return true.
if (sameValueZero(o[k], searchElement)) {
return true;
}
// c. Increase k by 1.
k++;
}
// 8. Return false
return false;
}
});
}

Dart TreeSanitzer: No static getter 'trusted' declared in class 'NodeTreeSanitizer'

I'm using the Bootjack Datepicker and after upgrading Dart to 1.12.1, I'm all of a sudden seeing only half a calendar with no days and with this exception:
Exception: No static getter 'trusted' declared in class
'NodeTreeSanitizer'. NoSuchMethodError: method not found: 'trusted'
Receiver: Type: class 'NodeTreeSanitizer'
This is the only line of code needed to wire the calendar:
Calendar.use();
If you need to manually wire the calendar, you can manually call:
Calendar.wire(querySelector("div.calendar"));
Both of them are giving me the exception in calendar.dart
The code that seems to be breaking is:
void _dayView() {
TableElement calBody = element.querySelector('.cnt');
Element dow = calBody.tBodies[0].createFragment(_DOW_TEMPLATE).children[0];
List<Element> children = dow.children;
List<String> swkDays = _dfmt.dateSymbols.SHORTWEEKDAYS;
int ofs = (_firstDayOfWeek + 1) % 7;
//render week days
for (int i = swkDays.length; --i >= 0;) {
children[i].text = swkDays[(i + ofs) % 7];
}
var buffer = new StringBuffer();
for (int i = 6; --i >= 0;) {
buffer.write(_DAYROW_TEMPLATE);
}
calBody.tBodies[0]
..append(dow)
..appendHtml(buffer.toString(), treeSanitizer: NodeTreeSanitizer.trusted); <<<<<<<< ERROR
}
Looking at appendHtml, I can see treeSanitizer is an optional param, so that syntax looks fine. In the abstract class NodeTreeSanitizer, I can see: static const trusted = const _TrustedHtmlTreeSanitizer();, so that seems to be fine as well.
Any idea what could be causing this error?
I've logged a bug here in the meantime: https://github.com/rikulo/bootjack-datepicker/issues/2
Looks like your Dartium version is outdated.
Please compare the output of dart --version (command line) and the Dart version on the about://version page in Dartium.

IE9 textangular issue

I'm receiving the following textangular error in IE9 or below.
unable to get the value of the property 'match': object is null or undefined textangular.js line 107 character 3
Here is the block of code that causes the error:
if(_browserDetect.ie > 8 || _browserDetect.ie === undefined){
var _sheets = document.styleSheets;
/* istanbul ignore next: preference for stylesheet loaded externally */
for(var i = 0; i < _sheets.length; i++){
if(_sheets[i].media.length === 0 || _sheets[i].media.mediaText.match(/(all|screen)/ig)){
if(_sheets[i].href){
if(_sheets[i].href.match(/textangular\.(min\.|)css/ig)){
sheet = _sheets[i];
break;
}
}
}
}
Line 107 is starts the first if block
TextAngular works correctly without error in all other browsers, just IE9 and below is returning the above error.

How to detect browser using angularjs?

I am new to angularjs. How can I detect userAgent in angularjs. Is it possible to use that in controller? Tried something like below but no luck!
var browserVersion = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
I need to detect IE9 specifically!
Like Eliran Malka asked, why do you need to check for IE 9?
Detecting browser make and version is generally a bad smell. This generally means that you there is a bigger problem with the code if you need JavaScript to detect specific versions of browser.
There are genuine cases where a feature won't work, like say WebSockets isn't supported in IE 8 or 9. This should be solved by checking for WebSocket support, and applying a polyfill if there is no native support.
This should be done with a library like Modernizr.
That being said, you can easily create service that would return the browser. There are valid cases where a feature exists in a browser but the implementation is outdated or broken. Modernizr is not appropriate for these cases.
app.service('browser', ['$window', function($window) {
return function() {
var userAgent = $window.navigator.userAgent;
var browsers = {chrome: /chrome/i, safari: /safari/i, firefox: /firefox/i, ie: /internet explorer/i};
for(var key in browsers) {
if (browsers[key].test(userAgent)) {
return key;
}
};
return 'unknown';
}
}]);
Fixed typo broswers
Note: This is just an example of how to create a service in angular that will sniff the userAgent string. This is just a code example that is not expected to work in production and report all browsers in all situations.
UPDATE
It is probably best to use a third party library like https://github.com/ded/bowser or https://github.com/darcyclarke/Detect.js. These libs place an object on the window named bowser or detect respectively.
You can then expose this to the Angular IoC Container like this:
angular.module('yourModule').value('bowser', bowser);
Or
detectFactory.$inject = ['$window'];
function detectFactory($window) {
return detect.parse($window.navigator.userAgent);
}
angular.module('yourModule').factory('detect', detectFactory);
You would then inject one of these the usual way, and use the API provided by the lib. If you choose to use another lib that instead uses a constructor method, you would create a factory that instantiates it:
function someLibFactory() {
return new SomeLib();
}
angular.module('yourModule').factory('someLib', someLibFactory);
You would then inject this into your controllers and services the normal way.
If the library you are injecting does not exactly match your requirements, you may want to employ the Adapter Pattern where you create a class/constructor with the exact methods you need.
In this example we just need to test for IE 9, and we are going to use the bowser lib above.
BrowserAdapter.$inject = ['bowser']; // bring in lib
function BrowserAdapter(bowser) {
this.bowser = bowser;
}
BrowserAdapter.prototype.isIe9 = function() {
return this.bowser.msie && this.browser.version == 9;
}
angular.module('yourModule').service('browserAdapter', BrowserAdapter);
Now in a controller or service you can inject the browserAdapter and just do if (browserAdapter.isIe9) { // do something }
If later you wanted to use detect instead of bowser, the changes in your code would be isolated to the BrowserAdapter.
UPDATE
In reality these values never change. IF you load the page in IE 9 it will never become Chrome 44. So instead of registering the BrowserAdapter as a service, just put the result in a value or constant.
angular.module('app').value('isIe9', broswerAdapter.isIe9);
Angular library uses document.documentMode to identify IE . It holds major version number for IE, or NaN/undefined if User Agent is not IE.
/**
* documentMode is an IE-only property
* http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx
*/
var msie = document.documentMode;
https://github.com/angular/angular.js/blob/v1.5.0/src/Angular.js#L167-L171
Example with $document (angular wrapper for window.document)
// var msie = document.documentMode;
var msie = $document[0].documentMode;
// if is IE (documentMode contains IE version)
if (msie) {
// IE logic here
if (msie === 9) {
// IE 9 logic here
}
}
you should use conditional comments
<!--[if IE 9]>
<script type="text/javascript">
window.isIE9 = true;
</script>
<![endif]-->
You can then check for $window.isIE9 in your controllers.
Not sure why you specify that it has to be within Angular. It's easily accomplished through JavaScript. Look at the navigator object.
Just open up your console and inspect navigator. It seems what you're specifically looking for is .userAgent or .appVersion.
I don't have IE9 installed, but you could try this following code
//Detect if IE 9
if(navigator.appVersion.indexOf("MSIE 9.")!=-1)
You can easily use the "ng-device-detector" module.
https://github.com/srfrnk/ng-device-detector
var app = angular.module('myapp', ["ng.deviceDetector"]);
app.controller('DeviceCtrl', ["$scope","deviceDetector",function($scope,deviceDetector) {
console.log("browser: ", deviceDetector.browser);
console.log("browser version: ", deviceDetector.browser_version);
console.log("device: ", deviceDetector.device);
}]);
So, you can declare more utilities for angular by create file with content (I follow RGraph Library)
(function(window, angular, undefined) {'use strict';
var agl = angular || {};
var ua = navigator.userAgent;
agl.ISFF = ua.indexOf('Firefox') != -1;
agl.ISOPERA = ua.indexOf('Opera') != -1;
agl.ISCHROME = ua.indexOf('Chrome') != -1;
agl.ISSAFARI = ua.indexOf('Safari') != -1 && !agl.ISCHROME;
agl.ISWEBKIT = ua.indexOf('WebKit') != -1;
agl.ISIE = ua.indexOf('Trident') > 0 || navigator.userAgent.indexOf('MSIE') > 0;
agl.ISIE6 = ua.indexOf('MSIE 6') > 0;
agl.ISIE7 = ua.indexOf('MSIE 7') > 0;
agl.ISIE8 = ua.indexOf('MSIE 8') > 0;
agl.ISIE9 = ua.indexOf('MSIE 9') > 0;
agl.ISIE10 = ua.indexOf('MSIE 10') > 0;
agl.ISOLD = agl.ISIE6 || agl.ISIE7 || agl.ISIE8; // MUST be here
agl.ISIE11UP = ua.indexOf('MSIE') == -1 && ua.indexOf('Trident') > 0;
agl.ISIE10UP = agl.ISIE10 || agl.ISIE11UP;
agl.ISIE9UP = agl.ISIE9 || agl.ISIE10UP;
})(window, window.angular);
after that, in your function use can use it like
function SampleController($scope){
$scope.click = function () {
if(angular.ISCHROME) {
alert("is chrome");
}
}
I modified the above technique which was close to what I wanted for angular and turned it into a service :-). I included ie9 because I was having some issues in my angularjs app, but could be something I'm doing, so feel free to take it out.
angular.module('myModule').service('browserDetectionService', function() {
return {
isCompatible: function () {
var browserInfo = navigator.userAgent;
var browserFlags = {};
browserFlags.ISFF = browserInfo.indexOf('Firefox') != -1;
browserFlags.ISOPERA = browserInfo.indexOf('Opera') != -1;
browserFlags.ISCHROME = browserInfo.indexOf('Chrome') != -1;
browserFlags.ISSAFARI = browserInfo.indexOf('Safari') != -1 && !browserFlags.ISCHROME;
browserFlags.ISWEBKIT = browserInfo.indexOf('WebKit') != -1;
browserFlags.ISIE = browserInfo.indexOf('Trident') > 0 || navigator.userAgent.indexOf('MSIE') > 0;
browserFlags.ISIE6 = browserInfo.indexOf('MSIE 6') > 0;
browserFlags.ISIE7 = browserInfo.indexOf('MSIE 7') > 0;
browserFlags.ISIE8 = browserInfo.indexOf('MSIE 8') > 0;
browserFlags.ISIE9 = browserInfo.indexOf('MSIE 9') > 0;
browserFlags.ISIE10 = browserInfo.indexOf('MSIE 10') > 0;
browserFlags.ISOLD = browserFlags.ISIE6 || browserFlags.ISIE7 || browserFlags.ISIE8 || browserFlags.ISIE9; // MUST be here
browserFlags.ISIE11UP = browserInfo.indexOf('MSIE') == -1 && browserInfo.indexOf('Trident') > 0;
browserFlags.ISIE10UP = browserFlags.ISIE10 || browserFlags.ISIE11UP;
browserFlags.ISIE9UP = browserFlags.ISIE9 || browserFlags.ISIE10UP;
return !browserFlags.ISOLD;
}
};
});
There is a library ng-device-detector which makes detecting entities like browser, os easy.
Here is tutorial that explains how to use this library. Detect OS, browser and device in AngularJS
ngDeviceDetector
You need to add re-tree.js and ng-device-detector.js scripts into your html
Inject "ng.deviceDetector" as dependency in your module.
Then inject "deviceDetector" service provided by the library into your controller or factory where ever you want the data.
"deviceDetector" contains all data regarding browser, os and device.
Why not use document.documentMode only available under IE:
var doc = $window.document;
if (!!doc.documentMode)
{
if (doc.documentMode === 10)
{
doc.documentElement.className += ' isIE isIE10';
}
else if (doc.documentMode === 11)
{
doc.documentElement.className += ' isIE isIE11';
}
// etc.
}
Browser sniffing should generally be avoided, feature detection is much better, but sometimes you have to do it. For instance in my case Windows 8 Tablets overlaps the browser window with a soft keyboard; Ridiculous I know, but sometimes you have to deal with reality.
So you would measure 'navigator.userAgent' as with regular JavaScript (Please don't sink into the habit of treating Angular as something distinct from JavaScript, use plain JavaScript if possible it will lead to less future refactoring).
However for testing you want to use injected objects rather than global ones. Since '$location' doesn't contain the userAgent the simple trick is to use '$window.location.userAgent'. You can now write tests that inject a $window stub with whatever userAgent you wan't to simulate.
I haven't used it for years, but Modernizr's a good source of code for checking features. https://github.com/Modernizr/Modernizr/issues/878#issuecomment-41448059
Detection ie9+
var userAgent, ieReg, ie;
userAgent = $window.navigator.userAgent;
ieReg = /msie|Trident.*rv[ :]*11\./gi;
ie = ieReg.test(userAgent);
if (ie) {
// js for ie9,10 and 11
}

Zend framework Undefined class constant '' in Zend/Db/Select.php

There is a srange error in my Apache Log :
PHP Fatal error: Undefined class constant ''
This is on line 814 of de library (Zend framework 1.11) library/Zend/Db/Select.php
A look of the code :
if ($type == self::FROM) {
// append this from after the last from joinType
$tmpFromParts = $this->_parts[self::FROM];
$this->_parts[self::FROM] = array();
// move all the froms onto the stack
while ($tmpFromParts) {
$currentCorrelationName = key($tmpFromParts);
if ($tmpFromParts[$currentCorrelationName]['joinType'] != self::FROM) {
break;
}
$lastFromCorrelationName = $currentCorrelationName;
$this->_parts[self::FROM][$currentCorrelationName] = array_shift($tmpFromParts);
} }
That's strange because the undefined constant is empty.
THis fatal error appears some times but not at every load of pages.
Is it a release BUG of the zend framework?

Resources