L.circleMarker传单

时间:2016-12-17 15:20:13

标签: leaflet leaflet.markercluster

如何用L.circleMarker中的图标替换圆圈

var style_station = {
    radius: 12,
    stroke:false,
    weight: 1,
    opacity: 1,
    fillOpacity: 1,
    // color: '#00ABDC',
};

$。getJSON(" url",function(stationexits){          exitlayer = L.geoJson(stationexits,{             onEachFeature:onEachStation,             pointToLayer:function(feature,latlng){                返回L.circleMarker(latlng,style_station);             }         });

2 个答案:

答案 0 :(得分:1)

您必须返回L.Marker

只有这样你才能设置自己的图标。

答案 1 :(得分:0)

我不想使用L.Marker,因为L.circleMarker比L.marker有自己的优势

我在下面做了它为我工作

1)创建了像

这样的svg模式
    var style_busstops = {
        radius: 12,
        stroke:false,
        weight: 1,
        opacity: 1,
        fillOpacity: 1,
        className : 'bus_stops'
    };

L.geoJson(busstops, {
            pointToLayer: function (feature, latlng) {
            return L.circleMarker(latlng, style_busstops);
         }
});

2)在样式

中设置className
.bus_stops { 
   fill: url(#bustop_icon);
}

3)添加'填充'班级bus_stops中的css

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
android:orientation="vertical"
tools:context="Your-Activity-name-like-com.xyz.MainActivity">

<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar" />

<android.support.v7.widget.SearchView
    android:id="@+id/action_search"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:clickable="true"
    android:title="@string/action_search">
</android.support.v7.widget.SearchView>