我刚从Apple Maps切换到Google Maps.我似乎无法找到答案的问题是如何使GMSMarker的图标从中心开始,而不是从图像的底部开始.
我的意思是当前位置点图标以其要表达的坐标为中心开始.但是,GMSMarkers图标从图标的底部开始.
我正在开发一个iOS应用程序.在该应用程序中,我有两个字段From和To.我使用谷歌自动完成API输入地址.我也能够获得2个地方的纬度和经度,并能够显示标记GMSMapView.
现在我想画这两个地方之间的路线.我们在使用时找到了解决方案MKMapView.但我无法找到解决方案GMSMapView.请帮我画出这两点之间的路线GMSMapView.
如果可能的话,请给我一些重要的链接.
谢谢.
我已合并以下内容:
GoogleMaps/GoogleMaps.h以及GoogleMapsM4B/GoogleMaps.h文件Obj-CAppDelegate.swift (didFinishLaunchingWithOptions)方法中手动输入iOS API密钥.几乎所有其他人都建议的其他东西.我花了两天时间试图解决这个问题.有谁知道这个问题的解决方案?
控制台投诉是:
Run Code Online (Sandbox Code Playgroud)> "2015-08-17 18:02:19.899 Project[608:10014] ClientParametersRequest > failed, 3 attempts remaining (0 vs 6). Error > Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be > completed. (com.google.HTTPStatus error 400.)" UserInfo=0x790bc050 > {data=<CFData 0x7925cb40 [0x22da9a8]>{length = 145, capacity = 256, > bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}} > 2015-08-17 18:02:19.899 randoPracty[608:10014] Google Maps SDK for iOS > (M4B) version: 1.10.17867.0 2015-08-17 18:02:19.959 > randoPracty[608:10014] …
我要回来了 UIImageView in - (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker;
这UIImageView将通过URL动态加载图像SDWebImage.
正如文档中描述的标记信息窗口:
注意:每次在地图上显示信息窗口时,信息窗口都会呈现为图像.这意味着在其属性处于活动状态时对其属性的任何更改都不会立即可见.信息窗口的内容将在下次显示时刷新.
关键是在下载图像后,信息窗口不刷新并继续显示占位符图像,直到用户隐藏然后再显示它.
所以我需要强制刷新markerInfoWindow下载的图像块中的内容.
我已经通过以下代码创建了像CAShapeLayer的动画折线,我已经将CAShapeLayer添加为GMSMapiew的子图层,但是,如果我移动地图,图层将不会移动.在哪里添加图层,以便它与地图一起移动?
func layer(from path: GMSPath) -> CAShapeLayer {
let breizerPath = UIBezierPath()
let firstCoordinate: CLLocationCoordinate2D = path.coordinate(at: 0)
breizerPath.move(to: self.mapView.projection.point(for: firstCoordinate))
for i in 1 ..< Int((path.count())){
print(path.coordinate(at: UInt(i)))
let coordinate: CLLocationCoordinate2D = path.coordinate(at: UInt(i))
breizerPath.addLine(to: self.mapView.projection.point(for: coordinate))
}
let shapeLayer = CAShapeLayer()
shapeLayer.path = breizerPath.reversing().cgPath
shapeLayer.strokeColor = UIColor.green.cgColor
shapeLayer.lineWidth = 4.0
shapeLayer.fillColor = UIColor.clear.cgColor
shapeLayer.lineJoin = kCALineJoinRound
shapeLayer.lineCap = kCALineCapRound
shapeLayer.cornerRadius = 5
return shapeLayer
}
func animatePath(_ layer: CAShapeLayer) {
let pathAnimation = CABasicAnimation(keyPath: "strokeEnd")
pathAnimation.duration = 6 …Run Code Online (Sandbox Code Playgroud) 我要求在我当前的位置显示一个视图.如果设备旋转或位置将改变它将旋转.我研究很多,但得到所有代码,在某些位置有固定位置或角度但我没有固定位置.任何人都可以朝正确的方向开车.
我还使用了GMSMarker的旋转属性,但它不起作用.
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
if (newHeading.headingAccuracy < 0){
NSLog(@"heading accuracy < 0");
return;
}
// Convert Degree to Radian and move the needle
float oldRad = (- manager.heading.trueHeading) * M_PI / 180.0f;
float newRad = (- newHeading.trueHeading) * M_PI / 180.0f;
// Compass animation
CABasicAnimation *theAnimation;
theAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
theAnimation.fromValue = [NSNumber numberWithFloat:oldRad];
theAnimation.toValue = [NSNumber numberWithFloat:newRad];
theAnimation.duration = 0.5f;
[source.layer addAnimation:theAnimation forKey:@"animateMyRotation"];
// source.transform = CGAffineTransformMakeRotation(newRad)
// GMSMarker *source = [googleMap selectedMarker]; …Run Code Online (Sandbox Code Playgroud) objective-c google-maps-markers cllocationmanager ios gmsmapview
我正在使用谷歌地图视图,我想在地图上添加一个按钮,当点击时,将按钮移动到特定位置.我目前有一个按钮插座和一个连接到该按钮的动作.
@IBAction func locationTapped(_ sender: Any) {
print("tapped")
let location = GMSCameraPosition.camera(withLatitude: place.latitude, longitude: place.longitude, zoom: 17.0)
mapView.camera = location
}
Run Code Online (Sandbox Code Playgroud)
place存在但由于某种原因,相机不会让步.我尝试过不同版本的代码并查看了Google Maps文档,但没有一个选项可以产生结果.谁能告诉我我做错了什么?
我在GMSMapView上放置了100个GMSMarkers.如何删除所有GMSMarkers?
在适用于iOS的Google Sdk 1.6版中.
不推荐使用将保存GMSMarkers列表的标记数组(在GMSMapView(Overlays)文件中).通过使用这个我从GMSMapView中删除所有GMSMarker.
有没有其他方法可以从iOS中的GMSMapView中删除所有GMSMarker?
我在特定位置显示标记,并在Google地图上的地址标签中显示当前地址.
现在,我想通过移动谷歌地图来改变位置,但问题是当我移动地图时,我应该同时移动标记和地图,我应该在地址标签中显示该位置的地址.
我怎样才能做到这一点?
我试过这个:
let destinationMarker = GMSMarker(position: self.destinationLocation.coordinate)
let image = UIImage(named:"sourcemarker")
destinationMarker.icon = image
destinationMarker.draggable = true
destinationMarker.map = self.viewMap
//viewMap.selectedMarker = destinationMarker
destinationMarker.title = "hi"
destinationMarker.userData = "changedestination"
func mapView(mapView: GMSMapView, didEndDraggingMarker marker: GMSMarker)
{
if marker.userData as! String == "changedestination"
{
self.destinationLocation = CLLocation(latitude: marker.position.latitude, longitude: marker.position.longitude)
self.destinationCoordinate = self.destinationLocation.coordinate
//getAddressFromLatLong(destinationCoordinate)
}
}
Run Code Online (Sandbox Code Playgroud) 我正在整合谷歌地图sdk.一切正常.但是当第二个出现时如何删除特定标记(Pin Point).(我不使用Mapkit)
我想要以下内容:
如果我点击地图然后现在在该位置生成一个标记引脚,如果我点击地图上的另一个位置然后显示两个引脚但我想要移除旧的标记引脚.
我也用,
[self.mapView clear];
Run Code Online (Sandbox Code Playgroud)
但很明显GMSMapview中的所有其他标记点.
以下是在地图上添加图钉的代码:
GMSMapView *mapView;
GMSMarker *currLocMarker = [[GMSMarker alloc] init];
currLocMarker.map = nil;
[currLocMarker setTitle:NSLocalizedString(@"current_location_title", nil)];
currLocMarker.icon = [UIImage imageNamed:@"pin_fetch_location.png"];
currLocMarker.position = CLLocationCoordinate2DMake(pCoordinate.latitude, pCoordinate.longitude);
currLocMarker.map = self.mapView;
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题.. !!
提前致谢..:)
gmsmapview ×10
ios ×9
google-maps ×6
swift ×4
center ×1
ios7 ×1
iphone ×1
location ×1
marker ×1
objective-c ×1
xcode ×1