Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps: Uncaught TypeError: Type error

Tags:

google-maps

On a few pages, I've started getting the above error, but only in Chrome ...

Here is some simple code to demonstrate the error:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyD4uPYa8gidHCvCzXxEAalEzkEh94MhZYg&sensor=false"></script>
<script>function initializeMap() {
    myLatlng = new google.maps.LatLng(42.791968,3.035231);
        var myOptions = {
        zoom: 8,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);

        marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        title: 'Tonys Place - Luxury apartment near the beach'
        });   
}
google.maps.event.addDomListener(window, 'load', initializeMap);

</script>
</head>
<body>
<div id="map_canvas" style="width: 400px; height: 400px">
</div>
</body>
</html>

I'm stumped - any ideas appreciated !!!

Thanks

like image 954
ChrisB Avatar asked Dec 13 '25 22:12

ChrisB


1 Answers

I think this is the same problem I recently had. I solved it by adding 'optimized: false' as an option on my markers.

marker = new google.maps.Marker({
    position: myLatlng, 
    map: map,
    title: 'Tonys Place - Luxury apartment near the beach',
    optimized: false
});   

Marker Options

like image 125
jdehlin Avatar answered Dec 15 '25 23:12

jdehlin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!