Skip to content Skip to sidebar Skip to footer

Handle Click Event In Gmappanel Extjs

click event to map Implemented but nothing hapens.I am using MVC Extjs I know how to implement in javascript for example http://jsfiddle.net/fatihacet/ckegk/ simple click event but

Solution 1:

You have this creating the map and adding an event listener:

var trafficMap = Ext.getCmp('gmapForm');
google.maps.event.addListener(trafficMap, 'click', function(e) {    
    var lat = e.latLng.lat(); // lat of clicked pointvar lng = e.latLng.lng(); // lng of clicked pointvar markerId = getMarkerUniqueId(lat, lng); // an that will be used to cache this marker in markers object.var marker = new google.maps.Marker({
        position: getLatLng(lat, lng),
        map: map,
        id: 'marker_' + markerId
    });
});

So you're creating a map and assigning it to a variable called trafficMap. But then your event listener refers to a map variable called simply map, when you add a new marker: map: map

Change that to refer to the trafficMap variable, i.e.

var marker = new google.maps.Marker({
    position: getLatLng(lat, lng),
    map: trafficMap,
    id: 'marker_' + markerId
});

Or even just:

var marker = new google.maps.Marker({
    position: getLatLng(lat, lng),
    map: this,
    id: 'marker_' + markerId
});

Post a Comment for "Handle Click Event In Gmappanel Extjs"