GMap subgurim.net只显示灰色框

时间:2018-06-01 09:23:37

标签: c# asp.net

这是我的代码,从数据库中获取经度和经度并显示到gmap工具。它运行没有任何错误,我可以看到数据也正确,但没有在显示器上显示任何地图只有灰色框与由subgurim窗口供电。我是否需要添加任何其他内容才能看到地图。

 GLatLng mainLocation = new GLatLng(20.300000099999997, 50.4000000);
                GMap1.setCenter(mainLocation, 15);

                XPinLetter xpinLetter = new XPinLetter(PinShapes.pin_star, "S", Color.Blue, Color.White, Color.Chocolate);
                GMap1.Add(new GMarker(mainLocation, new GMarkerOptions(new GIcon(xpinLetter.ToString(), xpinLetter.Shadow()))));

                GeoLocationDB objLocationDB = new GeoLocationDB();
                GeoLocationList objLocationList = new GeoLocationList();
                DateTime dt1 = new DateTime();
                dt1 = new DateTime(Convert.ToInt32(txtDatePicker.Text.Split('/')[2].ToString()), Convert.ToInt32(txtDatePicker.Text.Split('/')[1].ToString()), Convert.ToInt32(txtDatePicker.Text.Split('/')[0].ToString()));
                DateTime dt2 = new DateTime();
                dt2 = new DateTime(Convert.ToInt32(txtDatePicker1.Text.Split('/')[2].ToString()), Convert.ToInt32(txtDatePicker1.Text.Split('/')[1].ToString()), Convert.ToInt32(txtDatePicker1.Text.Split('/')[0].ToString()));

                objLocationList = objLocationDB.GetListBySearch(txtStaff.Text,dt1,dt2);

                PinIcon p;
                GMarker gm;
                GInfoWindow win;
                foreach (var i in objLocationList)
                {
                    p = new PinIcon(PinIcons.car, Color.Cyan);
                    gm = new GMarker(new GLatLng(i.Longitude),
                        new GMarkerOptions(new GIcon(p.ToString(), p.Shadow())));

                    win = new GInfoWindow(gm, i.ShopName + " <a href='" + i.Address + "'>Address...</a>", false, GListener.Event.mouseover);
                    GMap1.Add(win);
                }

请帮我找到解决方案。提前致谢。

1 个答案:

答案 0 :(得分:0)

我只提供纬度,但数据是纬度和经度。现在将代码更改为以下工作正常。

&#13;
&#13;
   GLatLng mainLocation = new GLatLng(20.300000099999997, 50.4000000);
             GMap1.setCenter(mainLocation, 15);

             XPinLetter xpinLetter = new XPinLetter(PinShapes.pin_star, "S", Color.Blue, Color.White, Color.Chocolate);
             GMap1.Add(new GMarker(mainLocation, new GMarkerOptions(new GIcon(xpinLetter.ToString(), xpinLetter.Shadow()))));
            GMap1.addControl(new GControl(GControl.preBuilt.GOverviewMapControl));
            GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl));

            GeoLocationDB objLocationDB = new GeoLocationDB();
            GeoLocationList objLocationList = new GeoLocationList();
            DateTime dt1 = new DateTime();
            dt1 = new DateTime(Convert.ToInt32(txtDatePicker.Text.Split('/')[2].ToString()), Convert.ToInt32(txtDatePicker.Text.Split('/')[1].ToString()), Convert.ToInt32(txtDatePicker.Text.Split('/')[0].ToString()));
            DateTime dt2 = new DateTime();
            dt2 = new DateTime(Convert.ToInt32(txtDatePicker1.Text.Split('/')[2].ToString()), Convert.ToInt32(txtDatePicker1.Text.Split('/')[1].ToString()), Convert.ToInt32(txtDatePicker1.Text.Split('/')[0].ToString()));

            objLocationList = objLocationDB.GetListBySearch(txtStaff.Text, dt1, dt2);

            PinIcon p;
            GMarker gm;
            GInfoWindow win;
            foreach (var i in objLocationList)
            {
                p = new PinIcon(PinIcons.car, Color.Cyan);
                string str = i.Latitude;
                string[] values = str.Split(',');
                for (int s = 0; s < 1; s++)
                {
                    double lang =Convert.ToDouble(values[0].Trim());
                    double longi = Convert.ToDouble(values[1].Trim());

                    gm = new GMarker(new GLatLng(lang,longi),
                             new GMarkerOptions(new GIcon(p.ToString(), p.Shadow())));
               
                 win = new GInfoWindow(gm, i.ShopName + " <a href='" + i.Address + "'>Address...</a>", false, GListener.Event.mouseover);
                 GMap1.Add(win);

                }
            }
&#13;
&#13;
&#13;

同时我也把密钥放到了HTML代码中。

&#13;
&#13;
<cc1:GMap ID="GMap1" runat="server" Width="600px" Height="500px"
        enableHookMouseWheelToZoom="True" mapType="MapMaker_Normal" Key="abcd" 
&#13;
&#13;
&#13;