【发布时间】:2014-02-01 00:33:40
【问题描述】:
我的 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 如果您缩小地图,您会看到标记放置正确。但是,地图不断放大到错误的位置。
【问题讨论】:
-
pst 你在你的程序中的代码,这也发生在我身上,你肯定错过了一些东西
-
您的纬度和经度的顺序是否正确?
-
您确定您的边界框(即地图的视口)具有正确的纬度/经度值并且没有反转?
-
@Karl,是的,我确定。因为标记放置在正确的城市(在荷兰)。但是,地图放大了大西洋
-
@404Student - 如果你发布你的代码会有所帮助,这样我们就可以看到潜在的问题在哪里。
标签: vb.net google-maps google-maps-markers