我想使用我自己的def f(category_list):
n_categories = len(category_list)
return pd.Series(dict(zip(category_list, [1]*n_categories)))
df1 = df.set_index('Name').cards
.apply(f)
.add_prefix('Card_')
.fillna(0)
.astype(int)
.reset_index()
print (df1)
Name Card_A Card_B Card_C Card_D
0 John 1 1 0 0
1 Mary 1 1 1 0
2 Dan 1 0 0 1
3 Peter 1 0 1 0
4 Ed 1 0 1 1
更改pin
clustering
上的默认google-maps
,我需要帮助来解决这个问题。这是我的MainActivity.class
icon
这是我的MyItem.class
package com.example.bimaaldi.mapss;
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.maps.android.clustering.ClusterManager;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private ClusterManager<MyItem> mClusterManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
if (mMap == null) {
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng zoom = new LatLng(-7.966658, 112.631923);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(zoom, 13));
mClusterManager = new ClusterManager <MyItem>(this, mMap);
mMap.setOnCameraChangeListener(mClusterManager);
mMap.setOnMarkerClickListener(mClusterManager);
addItems();
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
mMap.setMyLocationEnabled(true);
}
private void addItems(){
mClusterManager.addItem(new MyItem(-7.976557,112.628464));
mMap.addMarker(new MarkerOptions()
.title("Pia Cap Mangkok")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.kue)));
mClusterManager.addItem(new MyItem(-7.959904, 112.632161));
mClusterManager.addItem(new MyItem(-7.966447, 112.633693));
mClusterManager.addItem(new MyItem(-7.974462, 112.636852));
mClusterManager.addItem(new MyItem(-7.952476, 112.618387));
mClusterManager.addItem(new MyItem(-7.985999, 112.638294));
mClusterManager.addItem(new MyItem(-7.982339, 112.634663));
mClusterManager.addItem(new MyItem(-7.976261, 112.617243));
mClusterManager.addItem(new MyItem(-7.975363, 112.626559));
mClusterManager.addItem(new MyItem(-7.974657, 112.623750));
}
}
我应该在代码中添加什么。 谢谢。