Wednesday, March 28, 2012

Virtual Earth - Pushpin Layer not Updated

i'm trying to implement geotagging on my website that allow my blog reader to add themselves to the map using pushpin.under my map i've several field for the users to key in their details then upon clicking the "add" button... their details will be appended to a georss xml file... and this step works fine as the details can be appended without problem... but when the page refreshes after my user hav clicked the "add" button... the details added are not shown... and even click "refresh" on IE wont help... all i got to do to get the newly added details shown is to close the current IE and re-request the page in a new IE... then all the pushpins(including the last pushpin added) can be shown... y is this problem occuring? am i doing anything wrong??Thanks,Any chance you can post the code so I can see if you are doing anything wrong?

Thanks for your fast reply...well... here's my code:

to load the map:

1 var map = null;2 var layerid = 1;34 function AddMyLayer()5 {6 var veLayerSpec = new VELayerSpecification();7 veLayerSpec.Type = VELayerType.GeoRSS;8 veLayerSpec.ID = layerid;9 veLayerSpec.LayerSource = 'Location.xml';10 veLayerSpec.Method = 'get';11 map.AddLayer(veLayerSpec);12 }
to add pushpin and get the position:
1 function AddPin()2 {3 var pin = new VEPushpin(4 pinID,5 map.GetCenter(),6 null,7 null,8 null9 );10 map.AddPushpin(pin);1112 if (pinID != 1)13 {14 var intpin = pinID - 1;15 map.DeletePushpin(intpin);16 }1718 document.getElementById('<%=lblPosition.ClientID%>').innerText = map.GetCenter();19 pinID++;20 }
asp.net code to store position and details to XML
1Protected Sub btnAdd_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)2Dim xmldocAs New XmlDocument3 xmldoc.Load(Server.MapPath("Location.xml"))4Dim eleItemAs XmlElement = xmldoc.CreateElement("item")5Dim eleTitleAs XmlElement = xmldoc.CreateElement("title")6Dim textTitleAs XmlText = xmldoc.CreateTextNode(txtName.Text)7Dim eleBlogAs XmlElement = xmldoc.CreateElement("link")8Dim textBlogAs XmlText = xmldoc.CreateTextNode(txtBlog.Text)9Dim elePositionAs XmlElement = xmldoc.CreateNode(XmlNodeType.Element,"georss","point","http://www.georss.org/georss")10Dim strPositionAs String = Request.Form("lblPosition") // to get position11Dim textPositionAs XmlText = xmldoc.CreateTextNode(strPosition)12Dim eleDescAs XmlElement = xmldoc.CreateElement("description")13Dim textDescAs XmlText = xmldoc.CreateTextNode(txtDesc.Text)1415 eleItem.AppendChild(eleTitle)16 eleTitle.AppendChild(textTitle)17 eleItem.AppendChild(eleBlog)18 eleBlog.AppendChild(textBlog)19 eleItem.AppendChild(elePosition)20 elePosition.AppendChild(textPosition)21 eleItem.AppendChild(eleDesc)22 eleDesc.AppendChild(textDesc)2324Dim rootAs XmlElement = xmldoc.Item("feed")25 root.AppendChild(eleItem)2627 xmldoc.Save(Server.MapPath("Location.xml"))2829 Response.Redirect("Map.aspx?Session=" + DateTime.Now.Millisecond.ToString + DateTime.Now.Second.ToString + DateTime.Now.Minute.ToString)3031End Sub
so what do you think? is that the XML is being cache by Virtual Earth? so even the XML is updated... but VE is still refering to the cache data?
thanks... 

Actually I do not see anything wrong as far as I can tell. What do you get on this line?:
document.getElementById('').innerText = map.GetCenter();My only guess is you don't get the right Client ID? Otherwise I'm lost sorry

document.getElementById('').innerText = map.GetCenter();
this line is to get the position of the pushpin to be stored in the XML file...

actually as you said... the code has no problem and is working fine... it can add pushpin on the map... and after clicking "Add" button... all the information such as Name, position etc. can be appended to the XML file...

but now the problem is... even all the information are appended correctly... but the appended information cannot be shown...

let say i've one set of information in my XML file... then when the first time i start my page... the pushpin can be shown on the map... then i add another pushpin... and click "Add"... the page refreshes... appending the XML file... but the map(or the pushpin layer) is not updated...

i have to close my IE and restart it to get my second pushpin to be shown... refreshing wont help... neither does CTRL + F5... that is the only problem which i think is VE's problem... haha...

any clue? haha...

No comments:

Post a Comment