Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot read property '__e3_' of undefined

I'm developing an application with VB.NET and Google Maps v3 and trying create a map with these properties:

<script type="text/javascript"> 
    $(document).ready(function (){ 
        var sPath ="images/AppIcons/Vehicles/icon05.png,";
        var markers= new google.maps.Marker({
            position : new google.maps.LatLng(4.759915, -74.04083),
            map : map,
            icon : new google.maps.MarkerImage(+ sPath + null, null, null, new google.maps.Size(32, 32)),
            animation: google.maps.Animation.DROP,
            title : "buena"
        });
        var myLatlng = new google.maps.LatLng(0, 0);
        var mapOptions={zoom: 3,center: new google.maps.LatLng(4.590798,-74.084244),mapTypeId: google.maps.MapTypeId.ROADMAP };
        var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
        var marker = setMarkers(map);
        var infowindow = new google.maps.InfoWindow({Content : '<b>FM3200 - FM3200</b><div><font size=1>&nbsp;</font></div><div><u>20/01/2013 04:30:56 p.m. - Voltaje Externo - (Norte)</u></div>Ubicacion Invalida In1:0 In2:0 In3:0 Batext:4.45V Vel:0 Odom:0 Ibutton:0 Oficina Principal Risk, Kmh: 0'});
        if (markers !='') {
            google.maps.event.addListener(marker, 'click', function() {
                infowindow.open(map,marker);
                /*if (marker.getAnimation() != null) {
                    marker.setAnimation(null);
                } else {
                    marker.setAnimation(google.maps.Animation.BOUNCE);
                }*/
            });
        }
    });
    function setMarkers(map,markers) {
        var marker =markers;
        if (marker !='') {
            return marker;
        }
    }</script>

When I run this code, this error message appears:

Uncaught TypeError: Cannot read property '__e3_' of undefined main.js:18 

How can I solve this error?

like image 338
Deathshoo7 Avatar asked Feb 21 '13 17:02

Deathshoo7


People also ask

What is cannot read property of undefined in JavaScript?

The TypeError: Cannot read property of undefined is one of the most common type errors in JavaScript. It occurs when a property is read or a function is called on an undefined variable. TypeError: Cannot read properties of undefined (reading x) Undefined means that a variable has been declared but has not been assigned a value.

What is the meaning of undefined in JavaScript?

Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.

Why can’t I call a function on an undefined variable?

In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.


1 Answers

Move the creation of map to the top of the function.

Currently you use map as map-option for markers, where it's expected to be a google.maps.Map-instance(but it's undefined, because the map isn't created yet)

like image 182
Dr.Molle Avatar answered Oct 11 '22 20:10

Dr.Molle