在Button Click事件中获取Subgurim Map Marker位置

时间:2013-10-19 11:52:31

标签: asp.net google-maps c#-3.0 subgurim-maps

我正在使用Subgurim Map根据输入地址设置标记。使用GMarker,我可以将其加载到Map中。

现在这个地址可能是错误的或附近的实际地址。所以我给客户机会用不同的Marker设置实际地址(当一个叫“Pick Bubble”按钮的按钮时会冒泡)

StringBuilder sb = new StringBuilder();
        sb.Append(txtAddress.Text.Trim());
        sb.AppendFormat(", {0}", txtCity.Text.Trim());
        sb.AppendFormat("- {0}", txtZipcode.Text.Trim());
        sb.Append(", Gujarat");
        sb.AppendFormat(", {0}", txtCountry.Text.Trim());

        GetAddressCordinates googleCordinate = new GetAddressCordinates(Constants.APP_SETTINGS.GoogleMapAPIKey);
        Coordinate cordinate = googleCordinate.GetCoordinates(sb.ToString());

        GLatLng gLatLng = new GLatLng();
        {
            gLatLng.lat = double.Parse(cordinate.Latitude.ToString());
            gLatLng.lng = double.Parse(cordinate.Longitude.ToString());
        }

        if (gLatLng != null)
        {
            GMarker gMarker;

            GIcon gIcon = new GIcon();
            gIcon.image = ResolveUrl(string.Format("~/Images/ActualFlag.png"));
            gIcon.shadow = ResolveUrl(string.Format("~/Images/Shadow.png"));
            gIcon.shadowSize = new GSize(30, 30);
            gIcon.iconSize = new GSize(24, 24);

            GMarkerOptions mOpts = new GMarkerOptions();
            mOpts.draggable = true;
            mOpts.RaiseOnDrag = true;
            mOpts.Animation = GMarkerOptions.AnimationType.Bounce;
            mOpts.icon = gIcon;

            gMarker = new GMarker(gLatLng, mOpts);

            GInfoWindow infoWindow = new GInfoWindow(gMarker, "", false);

            GMap1.addInfoWindow(infoWindow);
            //GMap1.addGMarker(gMarker);

            string jsFunction = string.Format("function(){{ var ev = new serverEvent('dragend', 0); ev.addArg({0}.getPoint().lat()); ev.addArg({0}.getPoint().lng()); ev.send(); }}", gMarker.ID);

            GListener listener = new GListener(gMarker.ID, GListener.Event.dragend, "alertame");
            GMap1.Add(listener);
            GMap1.setCenter(gLatLng);
        }

现在我希望将这两个标记位置放入Button中,称为“NEXT”进行操作。

我将如何获得Marker职位?

1 个答案:

答案 0 :(得分:1)

您是否尝试将其放入GinfoWindow? 如下字符串:

 dir= "<input type='button' name='next'>"

成:

 GInfoWindow infoWindow = new GInfoWindow(gMarker, dir, false);