openlayers 3 - map.on click is not working in openlayers3 -


i trying click feature info on map click in openlayers3. getting error message in console typeerror: layer.getsource(...) null click function

 map.on('click', function (evt) {     var fl = map.foreachfeatureatpixel(evt.pixel, function (feature, layer) {         return { 'feature': feature, 'layer': layer };     });      var feature = fl.feature;     layer = fl.layer;     if (layer == vectorlayer) {         var admin = "<table>";         admin += "<tr><td style='color:green; border: 0px solid red;text-align:left;vertical-align:middle;font-size:15px;'><b>  information<b></td></tr>";         admin += "<tr><td><b>type</b></td><td>:</td><td >" + feature.get('field1') + "</td></tr>";         admin += "<tr><td><b>district</b></td><td>:</td><td>" + feature.get('district') + "</td></tr>";         admin += "<tr><td><b>taluk</b></td><td>:</td><td >" + feature.get('taluk') + "</td></tr>";         admin += "<tr><td><b>village</b></td><td>:</td><td>" + feature.get('village') + "</td></tr>";         admin += "<tr><td><b>code</b></td><td>:</td><td>" + feature.get('field2') + "</td></tr>";         $("#identifier").html(schooladmin);         $("#identifier").dialog('open');         schooladmin += "</table>";       } }); 

that's not click function, that's pointermove function, if want use click interaction you'll have change catched event singleclick, :

map.on('singleclick', function(evt){    //... }); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -