此代码无效
protected void Page_Load(object sender,EventArgs e) { if(!IsPostBack) { InitializeServerSide(); ConfigureClientSide(); } }
private void InitializeServerSide()
{
GLatLng latlng = new GLatLng(39, -0.5);
GMarker marker = new GMarker(latlng);
GMap1.Add(marker);
InitializeClientSide(marker.ID);
}
private void InitializeClientSide(string markerId)
{
btnGInfoWindow.Attributes.Add("onclick", string.Format("windowMe("+ markerId +");"));
}
private void ConfigureClientSide()
{
string js = string.Format(@"function windowMe(markerId){{var marker = getGMapElementById(subgurim_GMap1,markerId); marker.openInfoWindowHtml('Hello world!'); }}", GMap1.GMap_Id);
GMap1.addCustomJavascript(js);
}
答案 0 :(得分:3)
试试这个,
private void InitializeServerSide()
{
GMap1.addInfoWindow(GetInfoWindow(new GLatLng(7.225261, 80.198994)));
}
protected GInfoWindow GetInfoWindow(GLatLng loc)
{
GIcon icon = new GIcon();
icon.image = "http://localhost:9477/icons/red.png";
icon.shadow = "http://localhost:9477/icons/shadow.png";
icon.iconSize = new GSize(50, 50);
icon.shadowSize = new GSize(0, 0);
icon.iconAnchor = new GPoint(6, 18);
icon.infoWindowAnchor = new GPoint(0, 0);
GMarkerOptions mOpts = new GMarkerOptions();
mOpts.icon = icon;
GMarker marker = new GMarker(loc, mOpts);
GInfoWindow infoWindow = new GInfoWindow(marker, "Line ID: <a href=\"http://google.com\" target=\"_blank\">sachinda</a>", GListener.Event.click);
return infoWindow;
}