从kml图层自定义谷歌地图上的标记

时间:2017-01-18 18:02:32

标签: android google-maps kml markers

我正在从kml图层加载我的应用中的地图,kml文件各有几个标记。我想自定义那些,更具体地说,我想只显示没有标题的标记的描述。 这是kml的样子         

<name>Point 1</name>

<description>N</description>

<Point>

  <coordinates>-3.19144566846689,55.94300165613873,0</coordinates>

</Point>

我将kml放在我的代码中:

    public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);

    // set kml layers
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    InputStream inputStream = null;

    try {
        inputStream = new URL("http://www.inf.ed.ac.uk/teaching/courses/selp/coursework/monday.kml").openStream();

        // add a rectangle around the play area
        mMap.addPolyline(new PolylineOptions().geodesic(true)
                .add(new LatLng(55.946233,-3.192473)) //forest hill
                .add(new LatLng(55.946233,-3.184319)) // kfc
                .add(new LatLng(55.942617,-3.184319)) // buccleugh st bus stop
                .add(new LatLng(55.942617,-3.192473)) // meadows
        );

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e){
        e.printStackTrace();
    }
    try {
        layer = new KmlLayer(mMap, inputStream, getApplicationContext());
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        layer.addLayerToMap();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    }

我试图在文档中找到它,但我找不到如何仅显示有关地标的某些信息。

0 个答案:

没有答案