Show an infobox from a link
Hello everybody,
I'm working on this since yesterday, I can't solve it.
I have added 3 pushpin to the map
var
map =null;var
layer01=null;var
pinID = 1;varmapPopupID=0;var
iLoadError=0;var
tmpShapeToPopup=null;function
GetMap(){map =newVEMap("mapVE");map.SetDashboardSize(VEDashboardSize.Small);map.LoadMap(newVELatLong(13.4419, -87.1419), 5 ,'h' ,false);map.AttachEvent('onchangeview',ChangeViewManager);map.AttachEvent("onclick",ShapeLayerAlert);layer01 =newVEShapeLayer();layer01.SetTitle("layer01");map.AddShapeLayer(layer01);}
function
addPin(sLat,sLon,sImgPath,sTitle,sText){varshape =newVEShape(VEShapeType.Pushpin,newVELatLong((sLat), -(-sLon)));shape.SetTitle(sTitle);shape.SetDescription(sText);shape.SetCustomIcon(sImgPath);layer01.AddShape(shape)
pinID++;
returnshape.GetID();
}
the three points are displayed on the map and into a table as text.
Now what I'm trying to realize is an hyperlink the make a zoom to the point selected by the user and then display the infobox.
I have done the center and zoom procedure but there is no way to dispaly the infobox.
here is the hyperlink generated when I add the pushpin (the first parameter is the shapeID returned by the addPin function:
when the user click on the hyperlink the following function is called:
function
showPopup(tmpID,sLat,sLon){varobjCoords;mapPopupID=tmpID;objCoords=newVELatLong((sLat), -(-sLon));map.SetCenterAndZoom(objCoords, 9);
}
here is the function that manage the view change event:
function
ChangeViewManager(e){tmpShapeToPopup =layer01.GetShapeByID(mapPopupID);map.ShowInfoBox(tmpShapeToPopup)}
The problem is that the methodsshape.GetID() return a value that is not possible to use with the method
map
.GetShapeByIDIn order to use the methodsShowInfoBoxI need a shape object, and it seems that is not possible to retrieve it without an event that return this object.
to see the difference take a look at this function from MSDN:
function
ShapeLayerAlert(e){
if(e.elementID !=null){
shape =map.GetShapeByID(e.elementID);layer =shape.GetShapeLayer();alert("Shape ID " +e.elementID + "\nbelongs to shape layer '" +layer.GetTitle() + "'.");}
}
in my code is called when you click over a pushpin, try to replace e.elementID with shape.GetID() and you will see the issue!
please help me!!
thanks
Marco

