GeoRSS and Static point
I have a number of GeoRRS Layers that I am using to display various pushpins. I would like to also show one point on the map at all times. Here is what I am trying to do but something is not working right:
//Start of Script..............................
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
<script>
var myMap;
var tileLayer;
var tileSourceSpec;
function onPageLoad()
{
myMap = new VEMap('map1');
myMap.LoadMap(new VELatLong(45.45303010460688, -122.7883368730545), 17 ,'h' , false);
}
function AddPin()
{
var pin = new VEPushpin(
pinID,
new VELatLong(45.45303010460688, -122.7883368730545),
'icons/Pyramid.png',
'My pushpin',
'This is pushpin number '+pinID
);
map.AddPushpin(pin);
pinID++;
}
function GetGeo(id,where)
{...........rest of the code.................................
Hi builtbikes
From your sample seems you are adding multiple Pushpins to the same point of VELatLong(45.45303010460688, -122.7883368730545),
I would suggest you have your coordinates for the pushpins in arrays after you load them from geoRSS parsers
Let's see you have pinIDs[] for ids, lats[] for latitudes and lons[] for longitudes, then you loop and add your pushpins
for (var ind = 0; ind < lats.length; ind++)
{
var pLatLon = new VELatLong(lats[ind],lons[ind]);
var pinElement = document.getElementById('LMPin' + pinids[ind]);
var pin = null;
if (null==pinElement)
{
pin = new VEPushpin('LMPin' + pinids[ind],pLatLon,'icons/Pyramid.png','My Pushpin','Pushpin # '+pinids[ind]);
map.AddPushpin(pin);
}
}
For the static point, just add the pushpin separate outside of the loop.
Let me know if you need more details
Here is the whole code of what I am attempting.
<html>
<head>
<title>Alpha Resource Map</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="geo.css" />
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
<script>
var myMap;
var tileLayer;
var tileSourceSpec;
function onPageLoad()
{
myMap = new VEMap('map1');
myMap.LoadMap(new VELatLong(45.45303010460688, -122.7883368730545), 17 ,'h' , false);
}
function AddPin()
{
var pin = new VEPushpin(
pinID,
new VELatLong(45.45303010460688,-122.7883368730545),
'icons/Pyramid.png',
'My pushpin',
'This is pushpin number '+pinID
);
map.AddPushpin(pin);
pinID++;
}
function GetGeo(id,where)
{
if (document.getElementById(id).getAttribute('checked'))
{
try
{
tileSourceSpec = new VETileSourceSpecification();
tileSourceSpec.ID = where;
tileSourceSpec.TileSource = source;
tileSourceSpec.NumServers = 1;
myMap.AddTileSource(tileSourceSpec);
tileLayer = new VELayerSpecification(VELayerType.VETileSource,id,where);
tileLayer.ZIndex = 100;
tileLayer.Opacity = 1.0;
myMap.AddLayer(tileLayer);
}
catch (e)
{
if (e.name=='err_invalidsourceid')
{
tileLayer = new VELayerSpecification(VELayerType.VETileSource,id,where);
tileLayer.ZIndex = 100;
tileLayer.Opacity = 1.0;
myMap.AddLayer(tileLayer);
}
else alert(e.message);
}
}
else
{
myMap.DeleteLayer(id);
}
}
function GetEQs(id)
{
var state = document.getElementById(id).getAttribute('checked');
ClearChecks();
HideLayers();
// alert(state);
if (state)
{
document.getElementById(id).setAttribute('checked',true);
var url;
var icon;
switch (id)
{
case 0:
url = 'http://www.alphacommunity.com/mapping/sandwich.xml';
icon = 'icons/Deli.png';
break;
case 1:
url = 'http://www.alphacommunity.com/mapping/burger.xml';
icon = 'icons/Burger.png';
break;
case 2:
url = 'http://www.alphacommunity.com/mapping/coffee.xml';
icon = 'icons/Coffee.png';
break;
case 3:
url = 'http://www.alphacommunity.com/mapping/asian.xml';
icon = 'icons/Chinese.png';
break;
case 4:
url = 'http://www.alphacommunity.com/mapping/pizza.xml';
icon = 'icons/Pizza.png';
break;
case 5:
url = 'http://www.alphacommunity.com/mapping/bank.xml';
icon = 'icons/BanksAtms.png';
break;
case 6:
url = 'http://www.alphacommunity.com/mapping/gas.xml';
icon = 'icons/GasStation.png';
break;
case 7:
url = 'http://www.alphacommunity.com/mapping/lodging.xml';
icon = 'icons/Hotel.png';
break;
case 8:
url = 'http://www.alphacommunity.com/mapping/post.xml';
icon = 'icons/PostOffice.png';
break;
case 9:
url = 'http://www.alphacommunity.com/mapping/medical.xml';
icon = 'icons/Hospital.png';
break;
case 10:
url = 'http://www.alphacommunity.com/mapping/grocery.xml';
icon = 'icons/Groceries.png';
break;
}
try
{
tileLayer = new VELayerSpecification(VELayerType.GeoRSS,id,url,"GET",layerLoad,icon);
myMap.AddLayer(tileLayer);
}
catch (e)
{
if (e.name=='err_invalidlayerid')
{
myMap.ShowLayer(id);
}
else alert(e.message);
}
}
}
function ClearChecks()
{
document.getElementById(0).setAttribute('checked',false);
document.getElementById(1).setAttribute('checked',false);
document.getElementById(2).setAttribute('checked',false);
document.getElementById(3).setAttribute('checked',false);
document.getElementById(4).setAttribute('checked',false);
document.getElementById(5).setAttribute('checked',false);
document.getElementById(6).setAttribute('checked',false);
document.getElementById(7).setAttribute('checked',false);
document.getElementById(8).setAttribute('checked',false);
document.getElementById(9).setAttribute('checked',false);
document.getElementById(10).setAttribute('checked',false);
}
function HideLayers()
{
try{myMap.HideLayer(0);}catch(e){}
try{myMap.HideLayer(1);}catch(e){}
try{myMap.HideLayer(2);}catch(e){}
try{myMap.HideLayer(3);}catch(e){}
try{myMap.HideLayer(4);}catch(e){}
try{myMap.HideLayer(5);}catch(e){}
try{myMap.HideLayer(6);}catch(e){}
try{myMap.HideLayer(7);}catch(e){}
try{myMap.HideLayer(8);}catch(e){}
try{myMap.HideLayer(9);}catch(e){}
try{myMap.HideLayer(10);}catch(e){}
}
function layerLoad(e)
{
//alert(e.length);
}
</script>
<style>
body
{
font-family:Tahoma;
font-size:10pt;
background:url(bg.gif) top left repeat-x;
}
a
{
color:#ffddcc;
text-decoration:none;
}
a:hover
{
color:#668877;
text-decoration:none;
}
.cht_footer {
background:#CCCCCC;
position:absolute;
text-align:right;
padding:25px;
font-size:10pt;
color:#5c2946;
top:85%;
width:100%;
border-top:solid 1px #e7a614;
}
li, ul
{
list-style-type:square;
}
h5 {
border-bottom:#666666 1px dotted;
padding:2px 5px;
}
</style>
</head>
<body onLoad="onPageLoad()">
<div id="map1" class='mymap'></div>
<div id=titlebar class=titlebar><table width=100% style="height:8px;"><tr><td class=titlebar align=left>Alpha Area Map Resources</td><td align=right></td></tr></table>
</div>
<div class=optionsbox id='optdiv'>
<img src="icons/Deli.png" align="middle" class="icon"/><input value=1 id="0" title="Sandwiches" type="checkbox" onClick=GetEQs(0);"../>Sandwiches
<br /><br />
<img src="icons/Burger.png" align="middle" class="icon"/><input value=1 id="1" title="Burgers" type="checkbox" onClick=GetEQs(1);"../>Burgers
<br /><br />
<img src="icons/Coffee.png" align="middle" class="icon"/><input value=1 id="2" title="Coffee" type="checkbox" onClick=GetEQs(2);"../>Coffee
<br /><br />
<img src="icons/Chinese.png" align="middle" class="icon"/><input value=0 id="3" title="Asian" type="checkbox" onClick=GetEQs(3);"../>Asian
<br /><br />
<img src="icons/Pizza.png" align="middle" class="icon"/><input value=1 id="4" title="Pizza" type="checkbox" onClick=GetEQs(4);"../>Pizza
<br /><br />
<img src="icons/BanksAtms.png" align="middle" class="icon" /><input value=1 id="5" title="Bank and ATM" type="checkbox" onClick=GetEQs(5);"/>Banks and ATM
<br /><br />
<img src="icons/GasStation.png" align="middle" class="icon" /><input value=1 id="6" title="Gas" type="checkbox" onClick=GetEQs(6);"../>Gas
<br /><br />
<img src="icons/Hotel.png" align="middle" class="icon" /><input value=1 id="7" title="Lodging" type="checkbox" onClick=GetEQs(7);"../>Lodging
<br /><br />
<img src="icons/PostOffice.png" align="middle" class="icon" /><input value=1 id="8" title="Post Office" type="checkbox" onClick=GetEQs(8);"/>Post Office
<br /><br />
<img src="icons/Hospital.png" align="middle" class="icon" /><input value=1 id="9" title="Medical" type="checkbox" onClick=GetEQs(9);"../>Medical
<br /><br />
<img src="icons/Groceries.png" align="middle" class="icon" /><input value=1 id="10" title="Grocery" type="checkbox" onClick=GetEQs(10);"../>Grocery
<br /><br />
<br /> <br />
</div>
<img src="assetts/alpha.jpg" id="logo" title="Alpha Community Development Logo"/>
<!--<div class='cht_footer'> ©2006 Alpha Community Development </div> -->
</body>
</html>