I have a problem with EntityClickedListenerin Bing Maps. I encoded it in the following example:
map.setEntityClickedListener(new EntityClickedListener()
{
@Override
public void onAvailableChecked(String layerName, int entityId)
{
HashMap<String, Object> metadata = map.getLayerManager.GetMetadataByID(layerName, entityId);
Toast.makeText(Activity.this, metadata.toString(), Toast.LENGTH_LONG)
.show();
}
});
However, clicking on Pushpindoes nothing. I created a Toast post to see exactly what is in the metadata, but nothing happens. Looking through the application path, I can say that Bing uses the data service to retrieve its information:
bsds.FindByAreaCompleted = new Handler(){
public void handleMessage(Message msg) {
if(msg.obj != null){
Record[] records = (Record[])msg.obj;
EntityLayer el = (EntityLayer)bingMapsView.getLayerManager().getLayerByName(Constants.DataLayers.Search);
double maxLat = -90, minLat = 90, maxLon = -180, minLon = 180;
for(Record r : records){
Pushpin p = new Pushpin(r.Location);
p.Title = r.DisplayName;
HashMap<String, Object> metadata = new HashMap<String, Object>();
metadata.put("record", r);
el.add(p, metadata);
}
bingMapsView.setMapView(new LocationRect(maxLat, maxLon, minLat, minLon));
el.updateLayer();
}
};
I also edited the JavaScript file to remove some checks that might interfere with the work Listener:
this.ShowInfobox = function(entity){
window.BingMapsInterlop.entityClicked(entity.layerName, entityId);
};
var Layer = function(name, map, dataLayer)
{
this.Name = name;
var entities = new MM.EntityCollection(),
_map = map;
this.AddEntities = function(data)
{
if(data != null)
{
var i = data.length - 1;
if (i >= 0)
{
do
{
data[i].Entity.entityId = data[i].EntityId;
data[i].Entity.layerName = name;
data[i].Entity.title = data[i].title;
MM.Events.addHandler(data[i].Entity, 'click', function(e)
{
BingMapsAndroid.ShowInfobox(e.target);
});
entities.push(data[i].Entity);
}
while (i--)
}
}
};
};
Did I edit the JavaScript file correctly? I myself do not know JavaScript, and I am following this guide . It is added Pushpin, and I see it on BingMapsView, but the method OnClickdoes not execute. Is something missing?
, Bing Listeners Pushpin click, , . , . - ?