Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Regular Contributor
Posts: 234
Registered: ‎05-01-2016

custom feature attribute information - why function being called increasingly large number of times!

[ Edited ]

Below is my code to display a custom attribute information popup window when a parcel feature is clicked.  It works fine but the number of loops through the code starts at 1 and increases geometrically each time i click a parcel to get the custom display.  Eventually it takes it so long putting out the $GP.ui.info to 'Click on a Parcel', that the custom display stays blank for a noticeable amout of time. Ideally i would just like to have some code at startup that directs any click on a parcel to the custom code so the user doesn't have to click a tool button each time before clicking on the parcel. (I notice that after clicking the tool once it is not necessary to click it again in order to get custom attribute display for the next clicked parcel.)  Also until i added the timeout, the noncustom box would display along with the custom one for all parcel clicks after the first one.

 

function ParcelInfo() {
                $GP.ui.info("Click on a parcel");

                $GP.map.featureInfo({
                    preventDefaults: true // prevents the default feature info
                }, function (result) {
                    // placeholder for custom feature info implementation

                    var serializedResult = $GP.utils.serialize(result);
                  //  $GP.ui.info("in Parcel Info");
                    
                    var string1 = serializedResult;
                    //alert(string1);
                    if (serializedResult.indexOf("Parcels with Labels") < 0) {
                        $GP.ui.info(serializedResult.slice(1, 300));
                     //   $GP.ui.info("No parcel located");
                        return;
                    }
                     
                    
                    if (serializedResult.indexOf("Parcels with Labels") > 0) {
                        //alert(serializedResult);
                       // $GP.ui.info("index > 0");
                        var p1 = string1.indexOf("Parcel_ID") - 9;
                        var p2 = string1.indexOf(":false}") + 7;
                        var string3 = string1.slice(p1, p2);
                        var obj = JSON.parse(string3);
                        var Parcel_ID = obj.Value;
                        $GP.ui.info("Processing Parcel " + Parcel_ID);

                        var popup = window.open("http://cthse-gis/jd_portal/getParcelInfo.asp?parcelid=" + Parcel_ID, "Parcel Information", "location=1,status=1,scrollbars=1, width=300,height=800");
                       
                        popup.focus();
                        setTimeout(ParcelInfo, 5000);
                        $GP.ui.info("Parcel Information displayed");
                        
                    }
                }
                )
            }  

 

Contributor
Posts: 68
Registered: ‎02-10-2017

Re: custom feature attribute information - why function being called increasingly large number of ti

 

Have you tried to put the code in MapConfig.js file?

In a

Sys.Application.add_init(function() {}

?

Regular Contributor
Posts: 234
Registered: ‎05-01-2016

Re: custom feature attribute information - why function being called increasingly large number of ti

[ Edited ]

Thank you so much for all your help!  I tried adding to MapConfig.js - I  included my function in the {} on the line below.

 

Sys.Application.add_init(function(){}

I added this code at the top of MapConfig.js  right after the first few lines

 

// WEBGL MEMORY INITIALIZATION
window.Module = window.Module || {};
window.Module.TOTAL_MEMORY = 400000000;

Is there anything elsie i have to do? I removed adding the button from helloworld.js  

With new setup, i get the custom parcel display the first time, and the default one after that.

I know i am doing something wrong - will try to figure out what!

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.