Can't set location of Callout

2170
22
09-29-2020 12:00 PM
TimConfare1
New Contributor II

I've followed a couple Callout samples when creating my own but I can't get the location of the callout to display where I clicked or the xy coordinate of the feature I am selecting.  Every time the callout displays in the upper left of the screen like below:

Callouts appear to be pretty straightforward so I'm not sure why I can't get mine to work.  (I am using a mmpk)

property Point clickedPoint

calloutData {
    }
Callout {
        id: callout
        calloutData: parent.calloutData
        accessoryButtonHidden: true
        leaderPosition: leaderPositionEnum.Automatic
    }
onMouseClicked: {
        clickedPoint = mouse.mapPoint;
        var tolerance = 5,
        returnPopupsOnly = false,
        maximumResults = 1;
        mapView.identifyLayerWithMaxResults(featureLayer, mouse.x, mouse.y, tolerance, returnPopupsOnly, maximumResults);
    }

onIdentifyLayerStatusChanged: {
         if (identifyLayerStatus === Enums.TaskStatusCompleted) {
             featureLayer.clearSelection();
             const elem = identifyLayerResult.geoElements[0];
             const count = identifyLayerResult.geoElements.length;
             featureLayer.selectFeatures(elem);
             var featureName = elem.attributes.attributeValue("Name");
             var xcoord = elem.attributes.attributeValue("POINT_X");
             var ycoord = elem.attributes.attributeValue("POINT_Y");
             mapView.calloutData.geoElement = elem;
             mapView.calloutData.detail = featureName;
             mapView.calloutData.location = clickedPoint;
             callout.showCallout();
         }
    }
22 Replies
TimConfare1
New Contributor II

Very strange.  I copied your code above including the service you point to and I still get the same thing.  I can share my data so you can try on your end.   I sent you an invite to the group where my mobile map package is.

Thanks!

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Seems like data shouldn't make a difference since the feature service I sent doesn't work for you.

I'm unsure what the difference would be.

Could you try commenting out the following?

mapView.calloutData.location = clickedPoint;

I had a quick look at the internals and it seems like it expects you to either set the geoelement property or the location property. Setting location would be ideal for when you just want to click on the map and show a callout at that location. Setting the geoelement is ideal when you want to place the callout on a graphic or feature. I'm wondering if setting both is getting us into some strange race condition giving us different results.

0 Kudos
TimConfare1
New Contributor II

I have tried that and it still is in the upper left.  It stays there even if I zoom way out.  Do you think it matters what version of the ArcGIS Runtime SDK I have installed?  Currently I'm at 100.8.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Version shouldn't matter. Are you using AppStudio or building from source with the Qt SDK directly?

0 Kudos
TimConfare1
New Contributor II

I am using AppStudio

0 Kudos
TimConfare1
New Contributor II

I added a zip file of my app in the group in case you want to look at that.  It has to be something in my app.

Thanks for your time!

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Which group are you referring to? Do you have a link?

0 Kudos
TimConfare1
New Contributor II

Sorry...thought I could upload a zip file of my project to AGOL but it doesn't allow that.  

0 Kudos
LucasDanzinger
Esri Frequent Contributor

you can upload a zip file right here in GeoNet. You have to expand the toolbar on the top of the reply and select Use Advanced Editor, which will allow you to upload an attachment. Otherwise, on AGOL, I've uploaded zips in the past, but you need to mark them as "Code Sample".

0 Kudos
TimConfare1
New Contributor II

Got it.  Thanks!  I sent you an invite to my group.  I was able to upload the .zip file.

0 Kudos