2013-07-02 45 views
0

我的Google地图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如果缩小在地图上,你会看到标记放置正确。但是,地图不断放大错误的位置。

+1

PST你在程序有代码,这发生在我一会儿回来过,你失去了一些东西那肯定 – Pakk

+0

您的经度和纬度是否正确? – geocodezip

+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&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

希望这有助于