我的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如果缩小地图,您会看到标记放置正确。但是,地图会一直缩放到错误的位置。
答案 0 :(得分: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&ie=UTF8&ll=" & GLLat & "," & GLLong & "&spn=0.819443,1.454315&t=h&z=18&output=embed></iframe></body></html>
确保scrolling = no和z = 18,z是最初从
开始的缩放您必须自己将变量拼凑在一起:P
希望这会有所帮助