How can I center the GMSMapMarker view in a coordinate - ios

Is there a way to center the orange arrow (a GMSMapMarker) in a coordinate, changing the view frame or something? I'm using Google Maps for iOS. I can rotate the view with an angle, but I want to set the view's center in a custom coordinate.

I found the solution using the property groundAnchor of GMSMarker:
_mapMarker.groundAnchor = CGPointMake(0.5,0.5);

I think you can calculate the pixel/degree by using the GMSCoordinateBounds, then you can shift the center bases on your icon size and heading.

Related

Here maps offset position indicator center

I'm using the Here iOS SDK. I set position indicator via:
let mapMarker = NMAMapMarker(geoCoordinates: NMAGeoCoordinates(), icon: nmaImage)
mapView.positionIndicator.set(displayObject: mapMarker, toLayer: NMAMapLayerType.foreground)
That works, but position indicator apears at the center of the screen. I need to set some offset (or padding) in order to display position indicator way below the center (some offset or padding), so driver could see more of the road ahead.
You can set the map view's transform center: https://developer.here.com/documentation/ios-premium/api_reference_jazzy/Classes/NMAMapView.html#%2Fc:objc(cs)NMAMapView(py)transformCenter
Check also related SO posts
Here API offset map center and (for Android in that case) How to shift HERE Map View to the right when navigating

Objective c-How to move a marker up and down?

How to move the black marker over the image?
value=0+arc4random()%(100-0+1)...
CGFloat orignY=backgroundImage.frame.origin.y-(backgroundImage.frame.origin.y-0)*(value-0)/100;
marker.frame=CGRectMake(22,originY,width,height);
Tried this ,i get some random values and need to move the marker according to the value.
if value= 50 ,then marker should be at the center of the image..
How to achieve this....please help..
set the min and max values say
min=0,max=100
and let the first position of the marker be at the end of the image..so we get the y axis at that point.
set
oldY=marker.frame.origin.y
in the function to move the marker
marker.frame=CGRectMake(marker.frame.origin.x,oldY-(valuetomove-min)*heightofbackgroundimage/(max-min),marker.frame.size.width,marker.frame.size.height)

Center one image within another in Swift

I'm trying to center one image within another in Swift using the storyboard. I aligned Center X and Center Y, but the image is definitely offset. What am I doing wrong?
The frame is correctly placed, but the cat is offset. (The blue is for development only and will be made transparent once it's positioned.)
Cat attributes:
Frame attributes:
Storyboard:
Preview:
In this image you can see the ‘Align Center x’ Equals 56 You will need to set this value to 0. Same for the ‘Align Center y’.
The value behind the Equals defines an offset.

How do I find the lowest or highest point on a UIView being dragged with UIAttachmentBehavior?

Depending on where the anchorPoint is with UIAttachmentBehavior, the view can be quite rotated, so it's in more of a diamond shape than a square. In these situations, where it's rotated say 90°, how do I find what the lowest or highest point of this UIView is (in relation to the window)?
It's easy enough when the UIView is a (non-rotated) square, as I can just use CGRectGetMaxY (or min) and the x value doesn't matter, and then use convertPoint, but with the rotation the x value seems to have a real importance, as if I choose maxX, it will tell me the bottom right's point, while minX will give me the bottom left's.
I just want the lowest point that exists in the UIView. How do I get this?
EDIT: Here's some code showing how I'm attempting it currently:
CGPoint lowestPoint = CGPointMake(CGRectGetMinX(weakSelf.imageView.bounds), CGRectGetMaxY(weakSelf.imageView.bounds));
CGPoint convertedPoint = [weakSelf.imageView convertPoint:lowestPoint toView:nil];
The tracking of convertedPoint's y value completely changes depending on what I supply for the x value in lowestPoint's CGPointMake.
The view's frame is its bounding box. Normally you should be careful about using the frame of a transformed view, which is precisely what a rotated-by-UIKit-Dynamics view is. But it does give the info you are after.

How to detect the coordinates of a custom UIView on CPTPlotspace?

In my App, I am using Coreplot to draw a CPTScatterPlot. Now i want to do a scanner on the chart and this animation of UIView (a line) should be like a Line aligned with Y-axis and travels through x=0 to whatever the last value of x is.
I want to perform an action based on the y value while this custom UIView (scanner) travels.
Any help would be appreciated.
Thanks,
i have something similar in an app of mine, the way i went about it was to add a bar graph on top of the scatter plot, i used that bar graph to represent the line that tracks the user's touch.
then i have a UIView that is overlaid on the plot and tracks the scatter plot touches and displays details of the point being touched.
if you just want to display a line, adding a bar graph is probably the easiest, then you don't have to worry about plot space coordinates vs superview coordinates.
the bar graph data source is only returning a value for the location the user is touching, with a height to match the size of the scatter plot.
the quick version is you can use handlePlotTouchEventInSpace:atPoint:isNewEvent to track the user's touches on the graph.
from there you can use the plotPoint:forPlotAreaViewPoint method on the plot space to get the coordinates of the touch.
something like this is a good starting point. it's a bit of a journey to get it all working, but its not too bad once you get the puzzle started.
-(void)handlePlotTouchEventInSpace:(CPTPlotSpace *)space atPoint:(CGPoint)point isNewEvent:(BOOL)newEvent {
NSDecimal plotPoint[2];
CPTXYPlotSpace *xySpace = (CPTXYPlotSpace *)space;
[xySpace plotPoint:plotPoint forPlotAreaViewPoint:point];
after that plotPoint will contain the x and y location of the touch inside the plot space.

Resources