Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8221225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:49:59+00:00 2026-06-07T13:49:59+00:00

I’m having problem with the EntityClickedListener in Bing Maps. I coded it following the

  • 0

I’m having problem with the EntityClickedListener in Bing Maps. I coded it following the example given:

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 the the Pushpin does nothing. I created a Toast message to see exactly what’s in the metadata but nothing happens. Looking through the path the application, I can tell that Bing uses a 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’ve also edited the JavaScript file to remove some checking that may have prevented the Listener from working:

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;

                    // Commented out
                    // if(data[i].title != null && data[i].title != undefined && data[i].title != '')
                    // {
                        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--)
            }
        }
    };
    // fluff
};

Have I edited the JavaScript file correctly? I don’t know JavaScript myself and I’ve been following this guide. The Pushpin is being added and I’m seeing on my BingMapsView, but the OnClick method doesn’t execute. Is there something I’m missing?

The path that Bing takes to create Listeners and events for Pushpin click events is almost a labyrinth in my opinion. There has to be a simpler way to do this that I’m missing. Can anyone give any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:50:02+00:00Added an answer on June 7, 2026 at 1:50 pm

    I have finally found the answer! Edit the following methods in JavaScript file like so such that the script doesn’t check for metadata that doesn’t exist.

    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;
    
                        // Commented out
                        // if(data[i].title != null && data[i].title != undefined && data[i].title != '')
                        // {
                            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--)
                }
            }
        };
        // fluff
    };
    

    Then, change the ShowInfoBox method in the JavaScript file to

    this.ShowInfobox = function (entity) {
            window.BingMapsInterlop.entityClicked(entity.layerName, entity.entityId);
        };
    

    This code funnels straight to the click listener you code in your Activity instead of messing around with it in the JavaScript. The difference from the JavaScript I edited earlier is that the parameter for the entityClicked method should actually be entity.entityId not entityId.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
i got an object with contents of html markup in it, for example: string
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.