question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'apply' of undefined

See original GitHub issue

Hi there I am getting this error when I create map and add markers to it.

Uncaught TypeError: Cannot read property ‘apply’ of undefined at Map.trigger (BaseClass.js:62) at Map.js:195

Here is my code snippet: Am I doing anything wrong ?

function displayRestaurantResultsOnMap(data) {
  //Get all the restaurants info and parse the lat and long
  var JERSEY = new plugin.google.maps.LatLng(49.217231, -2.140589); //Center of JERSEY
  $("#searchmap-text").html('Loading...');
  setTimeout(function() {
    var div = document.getElementById("searchmap_canvas_div");
    $('#searchmap_canvas_div').css('height', $(window).height() - $('#searchmap_canvas_div').offset().top);
    mapNew = plugin.google.maps.Map.getMap(div, {
      'camera': {
        'latLng': JERSEY,
        'zoom': 12
      }
    });
    mapNew.on(plugin.google.maps.event.MAP_READY, searchMapInit(data));
  }, 1000);

}

function searchMapInit(data) {
  mapNew.clear();
  mapNew.setVisible(true);
  mapNew.setCameraZoom(11);



  //	var mData =[];
  $.each(data, function(key, val) {
    if (val.latitude) {
      var point = new plugin.google.maps.LatLng(val.latitude, val.longitude);
      var entry = {
        'position': point,
        'title': val.restaurant_name,
        'icon': {
          'url': 'https://www.cuisine.je/assets/images/menu-icon.png'
        }
      };
      //mData.push(entry);
      dump("marker options" + entry);
      //Add marker
      dump(mapNew)
      mapNew.addMarker(entry, function(marker) {
        dump("Marker added " + marker);
        // Display the infoWindow
        marker.showInfoWindow();
        marker.setAnimation(plugin.google.maps.Animation.BOUNCE);

      });
    }
  });


  $("#searchmap-text").html('Loaded!!');
  addSearchMarkers(mData, function(markers) {
    markers[markers.length - 1].showInfoWindow();
    markers[markers.length - 1].setAnimation(plugin.google.maps.Animation.BOUNCE);
  });

}

function addSearchMarkers(data, callbac) {
  var markers = [];

  data.forEach(function(markerOptions) {
    dump(markerOptions);
    mapNew.addMarker(markerOptions, onMarkerAdd);
  });

  function onMarkerAdd(marker) {
    dump("Marker added " + marker);
    markers.push(marker);
    if (markers.length === data.length) {
      callbac(markers);
    }
  }
}

Thanks and cheers Raj

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:25 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
cuisinejecommented, Nov 10, 2017

will do

1reaction
wf9a5m75commented, Nov 4, 2017

If you want to check your project by me, please share your project files on github or bitbucket.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'apply' of undefined · Issue #2359 - GitHub
When I use a regular browser like google chrome everything works as expected, then I used blisk I got an error saying app.js:14868...
Read more >
Redux TypeError: Cannot read property 'apply' of undefined
If you have the devtools disabled however, __REDUX_DEVTOOLS_EXTENSION__ is undefined and becomes the second argument to compose function.
Read more >
Error message "Cannot read property 'apply' of undefined"
When the UI Action is script is executed, this error is shown in the browser console: Uncaught TypeError: Cannot read property 'apply' of...
Read more >
Cannot read property 'apply' of undefined" - Forums - Liferay
In the console, persistent errors : "Uncaught TypeError: Cannot read property 'apply' of undefined" In what may be the reason?
Read more >
Uncaught TypeError: Cannot read property 'apply' of undefined
Uncaught TypeError : Cannot read property 'apply' of undefined · you are on master · you try with safe-mode if possible · give...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found