I am currently working on incorporating Google Maps to display locations extracted from a database. The locations consist of vending points that are grouped by promoters, and upon selecting a promoter, their vending points should be shown on the map. After initially using the Subgurim.net library, I decided to switch to a JavaScript implementation with guidance from https://www.codeproject.com/Articles/36151/Show-Your-Data-on-Google-Map-using-C-and-JavaScrip (however, I modified it to use GoogleMaps v3 calls). The JavaScript insertion works perfectly during page load, but when there is a postback related to a promoter code to display their vending points, although the data is loaded in the codebehind and reflected in the literal control, no markers appear on the webpage. Upon inspecting the generated page using Microsoft Edge's development tools, I notice that the literal control remains unchanged even after loading new data following postback. The ASPX section of the page is simple and not contained within an UpdatePanel, despite one being present on the page. I have also experimented with setting EnableViewState to both true and false on the literal control without any success.
This snippet shows the relevant part of the ASPX:
<div id="mapContent" >
<asp:Literal ID="mapJs" runat="server" EnableViewState="false" />
<div id="mapDiv" style="width:100%; height:640px;" />
<div id="infoDiv">
....
</div>
</div>
Here is part of the code that inserts the initial script:
StringBuilder map = new StringBuilder();
bool loadPVGiro = false;
double centerMapLat = 37.451669,
centerMapLong = 15.05263;
// Rest of the JavaScript code...
mapJs.Text = map.ToString();
The content generated on the page (from Edge's development tools):
<div id="mapContent" >
// Script generation...
</script>
<div id="mapDiv" style="width:100%; height:640px;" />
....
When a postback occurs after selecting a promoter code, the script is regenerated with the list of markers, yet the literal control still displays the original script. Although the literal control is updated with the new script (verified through debugging), the updated script does not reflect on the page. Any assistance in resolving this issue would be highly appreciated.
Rodolfo.
PS: I also attempted using ViewStateMode="disabled" on the literal control without any changes.
PS2> Additionally, I tried ClientScript.RegisterClientScriptBlock and ClientScript.RegisterStartupScript, but the scripts generated were identical to those within the literal control. It should be noted that the page resides within a MasterPage.