0

我的 Google-maps api 将地图加载到大西洋 - 海洋上,而我的标记指向其他地方。

我检查了我的代码,纬度和经度坐标是正确的,并且在地图上进行了标记。

有人可以帮我解决这个问题吗?

    Dim GeoLatitude As Double
    Dim GeoLongitude As Double
    Dim GoogleGeoCoderKey As String = keyvar
    Dim GoogleResult1 As GoogleResult
    GoogleResult1 = GoogleGeocoder.Geocode("streetname, PC City", GoogleGeoCoderKey) 'CurrentPage.PageName & " " & CurrentPage.BodyLeft
    If GoogleResult1.Status = GeocodeStatus.G_GEO_SUCCESS Then
        If GoogleResult1.Locations.Count = 1 Then
            For Each loc As Location In GoogleResult1.Locations()
                Dim latOld As String = loc.Point.Latitude.ToString()
                GeoLatitude = loc.Point.Latitude ' latOld.Replace(",", ".")
                Dim lonOld As String = loc.Point.Longitude.ToString()
                GeoLongitude = loc.Point.Longitude 'lonOld.Replace(",", ".")
            Next
        End If
    End If
    GoogleMap1.Width = 628
    GoogleMap1.Height = 300
    GoogleMap1.GoogleKey = keyvar
    GoogleMap1.Latitude = GeoLatitude
    GoogleMap1.Longitude = GeoLongitude
    GoogleMap1.Zoom = 15
    GoogleMap1.Options.MapTypes.Add(New Reimers.Map.CustomMaps.GoogleNormalMap())
    Dim tm As New Reimers.Map.CustomMaps.GoogleNormalMap()
    GoogleMap1.DefaultMap() = tm
    GoogleMap1.MapControls.Clear()
    GoogleMap1.MapControls.Add(New Reimers.Map.Controls.GoogleLargeMapControl("smc"))

If SubPagePartValue.SmallText1 <> "" And SubPagePartValue.SmallText2 <> "" Then
              GeoLatitude = CDbl(SubPagePartValue.SmallText1)
                GeoLongitude = CDbl(SubPagePartValue.SmallText2)
            End If
            If GeoLatitude = 0 Or GeoLongitude = 0 Then
                GoogleResult1 = GoogleGeocoder.Geocode(SubPages.BodyLeft, GoogleGeoCoderKey) 
If GoogleResult1.Status = GeocodeStatus.G_GEO_SUCCESS Then
                    If GoogleResult1.Locations.Count = 1 Then
                        For Each loc As Location In GoogleResult1.Locations()
                            Dim latOld As String = loc.Point.Latitude.ToString()
                            GeoLatitude = loc.Point.Latitude
                            Dim lonOld As String = loc.Point.Longitude.ToString()
                            GeoLongitude = loc.Point.Longitude
                            SubPagePartValue.SmallText1 = GeoLatitude
                            SubPagePartValue.SmallText2 = GeoLongitude
                            SubPagePartValue.Save()
                        Next
                    End If
                End If
            End If
Dim HTMLCode As String
            Dim gm As GoogleMarker = New GoogleMarker(SubPages.PageID)
            gm.Point.Latitude = GeoLatitude
            gm.Point.Longitude = GeoLongitude
            HTMLCode = "<div class=""GoogleMapsPopUp""><h1 class=""GoogleMapsPopUp"">" & SubPages.PageName & "</h1>"
            HTMLCode = HTMLCode & "<p class=""text""><a href=""" & SubPages.SEOURL(1) & """ title=""" & SubPages.SEOTitleTagLink & """>" & SubPages.PageName & "</a></p><p>" & SubPages.BodyLeft & "</p></div>"
            gm.MarkerText = HTMLCode
            gm.ClientSideHandlers.OnInfoWindowOpen = GoogleMap1.PanTo(gm.Point)
            gm.ClientSideHandlers.OnClick = gm.OpenInfoWindowHTML(GoogleMap1, gm.MarkerText)
            'gm.Options.Icon = SailpointIcon
            gm.Options.Title = Replace(SubPages.PageName, "'", "")
            GoogleMap1.Overlays.Add(gm)
        End If
    Next

实际结果可以在以下站点上查看:http: //www.stripdagenhaarlem.nl/Programma-Stripdagen-Haarlem.html ?cb=T如果您缩小地图,您会看到标记放置正确。但是,地图不断放大错误的位置。

4

1 回答 1

1

尝试加载变量以使代码看起来像

<html xmlns=http://www.w3.org/1999/xhtml><head><meta http-equiv=Content-Type content=text/html; charset=utf-8 /><body topmargin=0 leftmargin=0  ><iframe width=574 height=275 frameborder=0 scrolling=no marginheight=0 marginwidth=0 src=https://maps.google.com/maps?hl=en&amp;ie=UTF8&amp;ll=" & GLLat & "," & GLLong & "&amp;spn=0.819443,1.454315&amp;t=h&amp;z=18&amp;output=embed></iframe></body></html>

确保 scrolling=no 和 z=18,z 是它最初开始的缩放

您必须自己将变量拼凑在一起:P

希望这可以帮助

于 2013-07-08T12:32:07.543 回答