2012-06-27 23 views
0

我已經搜索過SO和Google,但沒有在此找到任何答案。Android MapView使用現有GoogleMap API

我正在傳遞以下數據,並需要在android中顯示它。 http://maps.google.com/maps/ms?msid=214791092532835797516.0004bc20df4e3c6ddf92a&msa=0&ll=52.812827,-2.079865&spn=0.003761,0.011689&amp

目前,我將它作爲其唯一元素顯示在帶有IFrame的webview中。但我真的需要在MapView中顯示它。我創建了一個MapView並使其工作。我現在需要在MapView中顯示數據,如上面的url所示。

雖然我可以看到緯度/經度值,是否有可能獲得自定義地圖,並將其添加到MapView?

+0

從鏈接,我可以看到你有一個業務層和3點與一些地方自定義的引腳。那麼你在問怎麼在mapView中做同樣的事情? – krishc

+0

@krishnakanthc我知道我可以在MapView中使用疊加並在GeoPoints中添加相同的功能。我想要實現的是,只要該URL可以提取數據並將其放在mapview上,或者理想情況下只需將URL傳遞給MapView,然後讓它工作即可。我目前的工作是使用該URL作爲數據啓動Google Maps應用程序。但是,我真的需要它在一個應用程序中,所以試圖使用地圖視圖,但不知道如何從URL中獲取自定義地圖數據。 – JonWillis

回答

1

嘗試從URL中獲取KML文件,msid將匹配。

https://maps.google.com/maps/ms?msid=214791092532835797516.0004bc20df4e3c6ddf92a&msa=0&ll=52.812827,-2.079865&spn=0.003761,0.011689

鏈接到KML文件將是:https://maps.google.com/maps/ms?ie=UTF8&authuser=0&msa=0&output=kml&msid=214791092532835797516.0004bc20df4e3c6ddf92a

你將不得不解析KML獲得位置

<?xml version="1.0" encoding="UTF-8"?> 
<kml xmlns="http://earth.google.com/kml/2.2"> 
<Document> 
    <name>Untitled</name> 
    <description><![CDATA[]]></description> 
    <Style id="style3"> 
    <IconStyle> 
     <Icon> 
     <href>http://maps.gstatic.com/mapfiles/ms2/micons/blue-dot.png</href> 
     </Icon> 
    </IconStyle> 
    </Style> 
    <Style id="style2"> 
    <IconStyle> 
     <Icon> 
     <href>http://maps.gstatic.com/mapfiles/ms2/micons/blue-dot.png</href> 
     </Icon> 
    </IconStyle> 
    </Style> 
    <Style id="style1"> 
    <IconStyle> 
     <Icon> 
     <href>http://maps.gstatic.com/mapfiles/ms2/micons/blue-dot.png</href> 
     </Icon> 
    </IconStyle> 
    </Style> 
    <Placemark> 
    <name>The Octagon</name> 
    <description><![CDATA[<div dir="ltr">This is the description for the octagon</div>]]></description> 
    <styleUrl>#style3</styleUrl> 
    <Point> 
     <coordinates>-2.081995,52.812881,0.000000</coordinates> 
    </Point> 
    </Placemark> 
    <Placemark> 
    <name>Sports centre</name> 
    <description><![CDATA[<div dir="ltr">This is the description for the sports centre</div>]]></description> 
    <styleUrl>#style2</styleUrl> 
    <Point> 
     <coordinates>-2.080439,52.812202,0.000000</coordinates> 
    </Point> 
    </Placemark> 
    <Placemark> 
    <name>Blackheath lane</name> 
    <description><![CDATA[]]></description> 
    <styleUrl>#style1</styleUrl> 
    <Point> 
     <coordinates>-2.072489,52.813522,0.000000</coordinates> 
    </Point> 
    </Placemark> 
</Document> 
</kml> 

我想這將讓你從URL中的位置,但我我不知道如何輕鬆自定義android地圖。

更新:

解析KML文件,計算器鏈接:How to draw a path on a map using kml file?

+0

使用KML文件,然後解析文件中的每個節點並顯示它們。乾杯 – JonWillis