2013-07-02 46 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

希望這有助於