Skip to main content

Hello, I am trying to create a report using the HTMLReportGenerator, for this case I want to show some maps according to an attribute they have, so I use the Group Processing option in the transformer by that specific attribute, but the output is just one map and a bunch of errors in the console. They say that "Map container is already initialized." or if I change all the global variables (var) that the report creates for scoped variables (let) the error says "Identifier 'map' has already been declared". Any ideas on how I can use this transformer for plotting multiple maps on a single page? Thanks.HTML report error

I think what happens is that it sets up each map with the same identifier, so by default it's not possible to do multiple maps in a single page.

What would potentially work, but is probably going to be a major hassle to implement, is using a StringSearcher to replace all instances of "map" after the first block of code containing the map with new, unique, identifiers per block/map.


I think what happens is that it sets up each map with the same identifier, so by default it's not possible to do multiple maps in a single page.

What would potentially work, but is probably going to be a major hassle to implement, is using a StringSearcher to replace all instances of "map" after the first block of code containing the map with new, unique, identifiers per block/map.

Thanks @Hans van der Maarel​ I have found a solution by keeping the global variables that the HTMLReportGenerator creates by default, I just have to create a different identifier for every <div> that contains a map, so I add a StringReplacer and look for the identifier of that div, I found out FME by default creates it with the name that the HTML transformer has, so at the beginning it was <div id ="mapHTMLReportGenerator1">, FME adds the "map" at the beginning and the "1" at the end (I don't know the reason). But I change the name of that transformer for something more identifiable for me. And then it worked and loaded.

 

Parameters in the StringReplacer I use.StringReplacerOverview of the resultOverview


Thanks @Hans van der Maarel​ I have found a solution by keeping the global variables that the HTMLReportGenerator creates by default, I just have to create a different identifier for every <div> that contains a map, so I add a StringReplacer and look for the identifier of that div, I found out FME by default creates it with the name that the HTML transformer has, so at the beginning it was <div id ="mapHTMLReportGenerator1">, FME adds the "map" at the beginning and the "1" at the end (I don't know the reason). But I change the name of that transformer for something more identifiable for me. And then it worked and loaded.

 

Parameters in the StringReplacer I use.StringReplacerOverview of the resultOverview

I just came across this post and this is the same solution that I ended up doing as well.

 

ezgif.com-gif-maker


Thanks @Hans van der Maarel​ I have found a solution by keeping the global variables that the HTMLReportGenerator creates by default, I just have to create a different identifier for every <div> that contains a map, so I add a StringReplacer and look for the identifier of that div, I found out FME by default creates it with the name that the HTML transformer has, so at the beginning it was <div id ="mapHTMLReportGenerator1">, FME adds the "map" at the beginning and the "1" at the end (I don't know the reason). But I change the name of that transformer for something more identifiable for me. And then it worked and loaded.

 

Parameters in the StringReplacer I use.StringReplacerOverview of the resultOverview

It looks really nice, thanks to share


Thanks @Hans van der Maarel​ I have found a solution by keeping the global variables that the HTMLReportGenerator creates by default, I just have to create a different identifier for every <div> that contains a map, so I add a StringReplacer and look for the identifier of that div, I found out FME by default creates it with the name that the HTML transformer has, so at the beginning it was <div id ="mapHTMLReportGenerator1">, FME adds the "map" at the beginning and the "1" at the end (I don't know the reason). But I change the name of that transformer for something more identifiable for me. And then it worked and loaded.

 

Parameters in the StringReplacer I use.StringReplacerOverview of the resultOverview

@warrengis are you able to share the reference to the above as it is exactly what I am trying to do as well


Thanks @Hans van der Maarel​ I have found a solution by keeping the global variables that the HTMLReportGenerator creates by default, I just have to create a different identifier for every <div> that contains a map, so I add a StringReplacer and look for the identifier of that div, I found out FME by default creates it with the name that the HTML transformer has, so at the beginning it was <div id ="mapHTMLReportGenerator1">, FME adds the "map" at the beginning and the "1" at the end (I don't know the reason). But I change the name of that transformer for something more identifiable for me. And then it worked and loaded.

 

Parameters in the StringReplacer I use.StringReplacerOverview of the resultOverview

@deanhowell​ ,

I would have to clean up the workspace in order to share it, but figured I could tell you how I built it, which should give you an example.

 

To start off I am using the html report generator to build the tables and the maps using Leaflet. After the tables and maps are built, I'm aggregating them onto a single feature, along with the html template. In my html template, I'm using syntax similar to jinja to replace the values with my actual table or map elements. 

 

Example: Replace {{ area_location_map }} with actual table <table> element or map that was built with the html report generator.

 

The html template contains all of my imports for javascript and css to apply to the tables and maps that are generated from the html report generator. In my example I'm using bootstrap 5 and leaflet. 

 

For the accordion, I'm using bootstrap 5 accordion. https://getbootstrap.com/docs/5.0/components/accordion/

 

21Example of my html template that I will find and replace with my actual table or map elements.

<div id="collapseOne" class="collapse" aria-labelledby="headingOne">
                <div class="card-body">
                    <div class="tableFixHead">
                        <p>Location map of the survey points. Click the icon on the map to view point information while
                            clicking the county boundary will provide the state and county name.</p>
                        <div id="map2HTMLReportGenerator_61" style="width:100%;height:100%;">
                            {{ area_location_map }}
                        </div>
                    </div>
                </div>
            </div>

 


Thanks @Hans van der Maarel​ I have found a solution by keeping the global variables that the HTMLReportGenerator creates by default, I just have to create a different identifier for every <div> that contains a map, so I add a StringReplacer and look for the identifier of that div, I found out FME by default creates it with the name that the HTML transformer has, so at the beginning it was <div id ="mapHTMLReportGenerator1">, FME adds the "map" at the beginning and the "1" at the end (I don't know the reason). But I change the name of that transformer for something more identifiable for me. And then it worked and loaded.

 

Parameters in the StringReplacer I use.StringReplacerOverview of the resultOverview

Thanks @Chris Warren​ that will be a great help :)


Reply