Tanvir Huda


Hello

I have developed a Virtual Earth application. The application renders some data from live geoRSS feed, parse the XML file and then add pushpin to the default 2D maps using the lat and lon value. Everything works file here.

But when i switched to 3D view of VE it doesnt display the pushpins. I even tried loading the 3D map as a default map and the result is same.

Can you please inform me whether i need to customize anything for that

Regards

Tanvir




Re: Cant display pushpin in 3D map control

Duncan Lawler


How are you adding the pin to the map Can you provide some sample code




Re: Cant display pushpin in 3D map control

Tanvir Huda

Hi Duncan

Thanks for your posting. Following is the code . I think adding it as a geoRSS layer would have solve my problem. If there are any alternatives in your mind please provide me some feedback.

for (var i=0; i<RSS.items.length; i++)
{
urlref = "<a href='javascript:;' oncontextmenu='return false'; onclick='ZoomZoom(new VELatLong("+RSS.itemsIdea.geolat+","+RSS.itemsIdea.geolong+"), 8)'>"
item_html = startItemTag;
var title = RSS.itemsIdea.title;
var parts=title.split(",");
var part = parts[0];
var mags = part.split(" ");
var mag = mags[1];
lat = RSS.itemsIdea.geolat;
lon = RSS.itemsIdea.geolong;
var depth = RSS.itemsIdea.depth;
var description = RSS.itemsIdea.description;
dateDiff(description);

if(datediff == 0){
if(mag >= 7.0) image = "images/bred.gif";
else image = "images/sred.gif";
}
else if(datediff == 1){
if(mag >= 7.0) image = "images/borg.gif";
else image = "images/sorg.gif";
}else{
if(mag >= 7.0) image = "images/byel.gif";
else image = "images/syel.gif";
}

item_html += (RSS.itemsIdea.title == null) "" : startTitle + urlref+RSS.itemsIdea.title + "</a>"+endTag;
item_html += magtag + "<B> Magnitude:</B>" + mag + endTag;
item_html += depthtag + "<B> Depth:</B>" + depth + endTag;
item_html += locationtag + "<B> Location:</B> ("+lat+","+lon+")" + endTag;
item_html += (RSS.itemsIdea.link == null) "" : startLink + "<a href='"+RSS.itemsIdea.link + "'><B> URL: </B>"+RSS.itemsIdea.link + "</a>" + endTag;
item_html += (RSS.itemsIdea.description == null) "" : startDescription + RSS.itemsIdea.description + endTag;
item_html += endTag;
document.getElementById("chan_items").innerHTML += item_html;

pin = new VEPushpin(
i+1, //id
new VELatLong(lat,lon), //location
image, //icon_url
RSS.itemsIdea.title, //title
item_html //details
);
map.AddPushpin(pin);


}






Re: Cant display pushpin in 3D map control

Derek Chan

In addition, Can you try the interactive SDK "Import data into shape layers" -> "add a GeoRSS layer" followed by switching to 3D mode If you can't see the pushpins in 3D, it sounds like a computer performance issue. I'm not seeing any issues adding GeoRSS Layers and showing them in 3D from my side.

I noticed that your using the old deprecated V4 method of manually adding pushpins. Keep in mind in V5 the model for adding pins is different and you may want to investigate into using shapes instead or going back to GeoRSS Feeds as they should work in 3D.

Hope that helps,




Re: Cant display pushpin in 3D map control

Duncan Lawler

One issue is the use of relative paths for the pin images. 3D needs full URI's.



Re: Cant display pushpin in 3D map control

Tanvir Huda

Hello Guys

I am able to successfully loaded geoRSS by adding a layer. The following is the code sample

function addlayer(){

var shapeLayer = new VEShapeLayer();

var shapeSpec = new VEShapeSourceSpecification(VEDataType.GeoRSS,"proxy.aspx", shapeLayer);

map.ImportShapeLayerData(shapeSpec, onFeedLoad,false);

}

function onFeedLoad(layer)

{

var numShapes = layer.GetShapeCount();

for(var i=0; i < numShapes; ++i)

{

var s = layer.GetShapeByIndex(i);

s.SetCustomIcon("<img src='images/borg.png'/>");

}

}

but the problem is, when i was adding pushpin i was able to add custom HTML which pops up on Mouseover function. Please see the following code. How can i do this in the above method. I mean when i am adding the GeoRSS as a separate layer how could i add custom HTML to it so that it could pops up on the MOUSEOVER function.

pin = new VEPushpin(

i+1, //id

new VELatLong(lon, lat), //location

image, //icon_url

RSS.itemsIdea.title, //title

item_html //details

);

map.AddPushpin(pin);

Thanks.

Regards

Tanvir






Re: Cant display pushpin in 3D map control

Derek Chan

Two options that I am aware of at the moment:

1) Throw the html directly into the xml file. You can set it inside the respective <title> and <description> tags. Keep in mind there are some special characters that you have to account for, so depending on how complex your html is, it can get messy. For example, take a look at the following anchor tag that redirects and alerts "hi" when clicked:

<description>&lt;a href=&quot;http://www.helloworld.com&quot;onclick=alert(&quot;hi&quotWink;&gt;&lt;a;&gt;click to go to helloworld site</description>

2) With VE5.0, you have direct access to the GeoRSS Layer and also the underlying pushpins (defined as shapes). You could add the GeoRSS layer on the map, then re-iterate through the shapes and re-add them in with the desired HTML.

I would recommend 1) if you don't have too much html to add, and if your not concerned with the xml file getting too big. With 2) you have a lot more control and can overcome the headache of the XML Special characters. However the drawback is that you'll need to figure out how you are going to re-add the pin without affecting visualization to the user.

I'll have to see if theres another way to dynamically add content to the bubble without pin re-adding but hopefully this can start things off.




Re: Cant display pushpin in 3D map control

Tanvir Huda

Hi Derek

I am getting a RSS Feed. So i cant manipulate the XML. So the only way to get the underlying pushpin and manipulate those.

Do you have any code sample how can i do that

Actually i need to replace the following functionality:

hope to hear from you soon.

if(datediff == 0){
if(mag >= 7.0) image = "images/bred.gif";
else image = "images/sred.gif";
}
else if(datediff == 1){
if(mag >= 7.0) image = "images/borg.gif";
else image = "images/sorg.gif";
}else{
if(mag >= 7.0) image = "images/byel.gif";
else image = "images/syel.gif";
}

item_html += (RSS.items.title == null) "" : startTitle + urlref+RSS.items.title + "</a>"+endTag;
item_html += magtag + "<B> Magnitude:</B>" + mag + endTag;
item_html += depthtag + "<B> Depth:</B>" + depth + endTag;
item_html += locationtag + "<B> Location:</B> ("+lat+","+lon+")" + endTag;
item_html += (RSS.items.link == null) "" : startLink + "<a href='"+RSS.items.link + "'><B> URL: </B>"+RSS.items.link + "</a>" + endTag;
item_html += (RSS.items.description == null) "" : startDescription + RSS.items.description + endTag;
item_html += endTag;
document.getElementById("chan_items").innerHTML += item_html;

pin = new VEPushpin(
i+1, //id
new VELatLong(lat,lon), //location
image, //icon_url
RSS.items.title, //title
item_html //details
);
map.AddPushpin(pin);





Re: Cant display pushpin in 3D map control

Tanvir Huda

Hi Duncan

Thanks for your feedback.

I have added the geoRSS layer and iterate through all the shapes and re-added them into the VE.

Here is a useful example of doing so,

http://blogs.msdn.com/keithkin/archive/2007/04/28/virtual-earth-api-importing-virtual-earth-collections-into-veshapelayers.aspx

But it cant display the custom pushpins in 3D maps. When i switched from 2D to 3D the custom pushpins disappear. Instead it shows the default pushpins in the maps.

I have even added the full URI in the s.SetCustomIcon("<img src='http://localhost/ve/hiking_icon.gif'/>");

But it is not working. How can i resolve this issue.

Thaks for your cooperation in advance.

Kind regards

Tanvir