none
BingMaps V8 and HtmlPushpin persist a JavaScript object and code behind call. RRS feed

  • Question

  • I am having a situation where I am using the HtmlPushpin and everything is working create UNTIL I need to do a code-behind call. 

    When that is done and it returns the HtmlPushpin object does not exist. 

    What options do I have a that point? 

    I am initially registering the module with the:

    Microsoft.Maps.registerModule('HtmlPushpinLayerModule', '../js/HtmlPushpinLayerModule.js');

    And when I have another code behind process execute and it returns back it's trying to use the HtmlPushPin object. It's obviously no longer present and I get an "HtmlPushpin is undefined" message. 

    Are there any options...can I load the module from the code-behind? 

    Any information would be greatly appreciated!

    Monday, July 17, 2017 9:10 PM

Answers

All replies

  • Set your code behind up to use AJAX. This will solve your issue, speed up your application, and will significantly reduce the number of transactions/map sessions your application generates. 


    [Blog] [twitter] [LinkedIn]

    Tuesday, July 18, 2017 2:04 AM
  • Can explain a little more on that? 

    Are you talking about using a webmethod with it? 

    Tuesday, July 18, 2017 3:54 AM
  • There are several ways to do this. The most common is ScriptManager: https://msdn.microsoft.com/en-us/library/bb398863.aspx Post back type architecture is ancient and should generally be avoided.

    [Blog] [twitter] [LinkedIn]

    Tuesday, July 18, 2017 4:58 PM
  • Actually one of the things I am finding it that the HtmlPushpin being undefined is from a refresh. 

    On the "GetMap" part, I am having it doing like an "AddStops()" function. 

    The AddStops() generated from the code-behind and does a JavaScript injection of the function and the stops. 

    It appears the code-behind is running first. Then the GetMaps (which calls the AddStops()) 

    At that point, the AddStops() function should already be there due to the JavaScript injection correct? 

    I have an alert in the "AddStops()" function as well as some pushpin creations. 

    That alert doesn't first UNLESS I have a button on the page that which I click calls the AddStops(). 

    I shouldn't need that button.

    Tuesday, July 18, 2017 5:50 PM
  • Actually, ended up working it out. It came down to the timing on when the page was rendered. 

    Thanks for all the possibilities info though! 

    Wednesday, July 19, 2017 4:17 PM