admin管理员组文章数量:1404041
I have a little Google Map with a few markers here: /
Since today (or maybe yesterday) there are suddenly errors popping up in the console, that I can't explain. The maps loads, but after a few seconds the errors pop up and you can't drag it anymore.
The code I use to initialize the map is (There is a little more to it with filters etc., but the errors pop up even when I switch off everything else):
google.load("maps", "3", {other_params:"sensor=false"});
function initialize() {
if($('.main.fullWidth').length > 0) var scroll = true;
else var scroll = false;
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(48.3, 14.3);
var myOptions = {
zoom: myZoom,
scrollwheel: scroll,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.ZOOM_PAN,
position: google.maps.ControlPosition.LEFT_BOTTOM
}
};
map = new google.maps.Map(document.getElementById("map"), myOptions);
}
$(document).ready(function(){
initialize();
});
The errors start of with: (few seconds after you load the page)
Uncaught TypeError: _.x is not a function / stats.js:9
Uncaught TypeError: Cannot set property 'Db' of undefined / mon.js:216
Uncaught TypeError: a.set is not a function / js?v=3&sensor=false:38
And after that if you move your mouse over the map you get constant:
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. / mon.js:31
Any ideas? The code might be messy, but this map has been up and running for years, why the sudden change?
Thank you for your help,
Florian
I have a little Google Map with a few markers here: http://www.magicbad./kontakt/fachbetrieb-karte/
Since today (or maybe yesterday) there are suddenly errors popping up in the console, that I can't explain. The maps loads, but after a few seconds the errors pop up and you can't drag it anymore.
The code I use to initialize the map is (There is a little more to it with filters etc., but the errors pop up even when I switch off everything else):
google.load("maps", "3", {other_params:"sensor=false"});
function initialize() {
if($('.main.fullWidth').length > 0) var scroll = true;
else var scroll = false;
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(48.3, 14.3);
var myOptions = {
zoom: myZoom,
scrollwheel: scroll,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.ZOOM_PAN,
position: google.maps.ControlPosition.LEFT_BOTTOM
}
};
map = new google.maps.Map(document.getElementById("map"), myOptions);
}
$(document).ready(function(){
initialize();
});
The errors start of with: (few seconds after you load the page)
Uncaught TypeError: _.x is not a function / stats.js:9
Uncaught TypeError: Cannot set property 'Db' of undefined / mon.js:216
Uncaught TypeError: a.set is not a function / js?v=3&sensor=false:38
And after that if you move your mouse over the map you get constant:
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. / mon.js:31
Any ideas? The code might be messy, but this map has been up and running for years, why the sudden change?
Thank you for your help,
Florian
Share Improve this question edited Nov 24, 2015 at 7:34 Florian Rachor asked Nov 23, 2015 at 17:10 Florian RachorFlorian Rachor 1,57415 silver badges31 bronze badges 2-
There is a syntax error in the posted code
Uncaught SyntaxError: Unexpected token )
, if I fix that (and definemyZoom
) it works for me – geocodezip Commented Nov 23, 2015 at 17:50 - Made that error when copy pasting the code here, the error is not there on the original page. The code worked for me, too, for a few years to be precise, but it stopped working overnight and throws errors without anybody working on the site. But seems to be a rather unmon error since nobody knows anything. – Florian Rachor Commented Nov 24, 2015 at 7:36
1 Answer
Reset to default 7Alright, I found the problem. I used an old form of including the Google Maps Api script. When I switch that to exactly this:
<script async defer
src="https://maps.googleapis./maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>
As mentioned in the GM basic tutorial here: https://developers.google./maps/documentation/javascript/tutorial it starts working again.
So if you run across any errors of this type, first check if you API inclusion is up to date.
本文标签: javascriptSudden errors on Google Map TypeError x is not a functionStack Overflow
版权声明:本文标题:javascript - Sudden errors on Google Map: TypeError: _.x is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744174926a2593953.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论