javascript - ASP: Dynamically update a Google Maps engine instance with new coordinates -


forgive me if doesn't make sense, i'm not 100% sure how ask i'm trying best , update post reflect advice people give me on clarifying question.

i have asp page calls google maps engine api through script runs on page load (just declared in page itself, not in pageload method). not knowing js or maps api followed google's instructions embedding in page , passing coordinates marker. need able feed updated coordinates object it's tracking changes position, map on page shows marker moving in "real-time" (5-second refresh). coordinates being updated in sql table , have data source pulling them on 5-second timer, have data on page, don't know how maps instance update when happens because it's got hard-coded coordinates in it.

so question is, best way go updating maps instance these changing coordinates? there way re-run script new coordinates? or should involve update panel somehow? going in wrong way? don't want have refresh entire page because affect performance , user experience.

for reference, page contains this:

<asp:updatepanel id="updatepanel1" runat="server" updatemode="conditional">     <triggers>         <asp:asyncpostbacktrigger controlid="timer1" eventname="tick" />     </triggers>     <contenttemplate>         <asp:label id="label2" runat="server" text="panel1 not refreshed yet"></asp:label>         <asp:radiobuttonlist id="radiobuttonlist1" runat="server" datasourceid="sqldatasource1" datatextfield="mac" datavaluefield="mac" height="28px" onselectedindexchanged="radiobuttonlist1_selectedindexchanged">         </asp:radiobuttonlist>     </contenttemplate> </asp:updatepanel> <script>   // js here calls map , adds coordinate </script> 

the update panel handles data source , updates list , label information data source every 5 seconds. script straight google's own examples of how embed map in page coordinate marker in it. think need add in panel rerun script when timer ticks, being unfamiliar asp i'm not sure how accomplish this. i've tried simple things pasting script inside of page crashes hits reference google api classes (big surprise). feel i'm frustratingly close can't make last simple connection. i'm used working c# applications can run loops want them , push updates whatever part of form need, integrating js in what's tripping me up. makes sense, it's late , i'm tired (:

update: i've got map load declaring script large scope possible in <script> element below head of page (that contains rest of c# code) , referencing scriptmanager.registerclientscriptblock in page_prerender method. loads map fine on page load, when timer ticks blanks out div map was. tries using this trick script execute every time panel updates (by putting button in panel , referencing in registerclientscriptblock method) seems re-register script every time there's tick event. if watch debugger can see header fill new references script it's registered each time. think i'm pretty darn close having figured out need rearranging things bit. reference, prerender code looks now, "script" being string containing script itself:

protected void page_prerender(object sender, eventargs e) {     scriptmanager.registerclientscriptblock(button1, button1.gettype(), "maprefresh", script, true); } 

yes should involve updatepanel asyncpostbacktrigger

http://msdn.microsoft.com/pt-br/library/system.web.ui.asyncpostbacktrigger(v=vs.100).aspx

but control trigger asyncpostbacktrigger timer 5sec updating coordinates, said.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -