iOS向けGoogleマップSDKの2013版を使用しています。現在の位置のデフォルトの青い点を別のアイコンでカスタマイズしたり、円を周回したりしたいと思います。現在地のGoogleマップの青い点をカスタマイズします。
私はMKMapViewでmapView:viewForAnnotation:
でこれを行うことができますが、Googleマップでどのように行うのか分かりません。
iOS向けGoogleマップSDKの2013版を使用しています。現在の位置のデフォルトの青い点を別のアイコンでカスタマイズしたり、円を周回したりしたいと思います。現在地のGoogleマップの青い点をカスタマイズします。
私はMKMapViewでmapView:viewForAnnotation:
でこれを行うことができますが、Googleマップでどのように行うのか分かりません。
現在のバージョンのSDK(1.4.3)でこれを行う方法はありません。実際には、このリクエストには未解決の問題があります:Look here。回避策として
、あなたがデフォルトボタンを非表示にすることができます。そして、GMSMarker
GMSMarker *pointMarker = [GMSMarker markerWithPosition:currentPosition];
pointMarker.icon = [UIImage imageNamed:@"YourImage"];
pointMarker.map = _map;
カスタムを作成し、CLLocationManager
を使用して、それの位置を変更するので、それは常に表示さ
_map.myLocationEnabled = NO;
現在の位置。ちょっと難しいですが、これを達成できると私は思っていました。より完全な例が必要な場合は、私に知らせてください。
スウィフト4
class MasterMapViewController: UIViewController, CLLocationManagerDelegate, GMSMapViewDelegate {
let currentLocationMarker = GMSMarker()
override func loadView() {
addCurrentLocationMarker()
}
func addCurrentLocationMarker() {
let currentLocationMarkerView = UIView()
currentLocationMarkerView.frame.size = CGSize(width: 40, height: 40)
currentLocationMarkerView.layer.cornerRadius = 40/4
currentLocationMarkerView.clipsToBounds = true
let currentLocationMarkerImageView = UIImageView(frame: currentLocationMarkerView.bounds)
currentLocationMarkerImageView.contentMode = .scaleAspectFill
currentLocationMarkerImageView.image = UIImage(named: "masterAvatar")
currentLocationMarkerView.addSubview(currentLocationMarkerImageView)
currentLocationMarker.iconView = currentLocationMarkerView
currentLocationMarker.isTappable = false
currentLocationMarker.map = mapView
}
// location manager delegate
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let lastLocation = locations.last!
currentLocationMarker.position = CLLocationCoordinate2D(latitude: lastLocation.coordinate.latitude, longitude: lastLocation.coordinate.longitude)
}
}
マーカーの動きがぎくしゃくし、マップ上の位置の一定の更新はかなりのパフォーマンスをドラッグすることができので、これは私にとって非常に魅力的な代替手段ではありません。しかし、これはそれがどのように行われたかです。
私は試しましたが、ユーザーの現在地周辺に複数のマーカーが表示されています。もっと精巧なコードを書いてください。 –
申し訳ありませんが、Gmapsを長年使用していませんが、この回答がまだ有効かどうかはわかりません。とにかく、問題がある場合は、新しい質問をしてください。私は古い回答を変更して問題を解決することはできません。 – Raspu
あなたの答えをありがとう。それは私の多くを助けます。 –