Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

How to properly set the Custom position for CalloutView? #1

Closed
hemangshah opened this issue Mar 13, 2018 · 12 comments
Closed

How to properly set the Custom position for CalloutView? #1

hemangshah opened this issue Mar 13, 2018 · 12 comments

Comments

@hemangshah
Copy link

func mapView(_ mapView: MapViewPlus, centerForCalloutViewOf annotationView: AnnotationViewPlus) -> CalloutViewPlusCenter {
        return .customCenter(self.mapViewPlus.center)
    }

With the current code, it's not working. Even I tried with other values too but it's not working.

@okhanokbay
Copy link
Owner

okhanokbay commented Mar 13, 2018

I just confirmed it's working. Did you set the calloutViewCustomizerDelegate of MapViewPlus? @hemangshah

@hemangshah
Copy link
Author

hemangshah commented Mar 13, 2018

It's going inside the delegate method but then it's not coming at the right place for me. @okhanokbay

Thanks for the quick response.

@okhanokbay
Copy link
Owner

okhanokbay commented Mar 13, 2018

In the example project's BasicCalloutView class, I added:

extension BasicCalloutView: CalloutViewCustomizerDelegate {
  func mapView(_ mapView: MapViewPlus, boundsForCalloutViewOf annotationView: AnnotationViewPlus) -> CalloutViewPlusBound {
    return .defaultBounds
  }
	
  func mapView(_ mapView: MapViewPlus, centerForCalloutViewOf annotationView: AnnotationViewPlus) -> CalloutViewPlusCenter {
    return .customCenter(CGPoint(x: 30, y: -200))
  }
}

Also, in the example project's BasicExampleViewController class, added:

mapView.anchorViewCustomizerDelegate = self into override func viewDidLoad() method

mapView.calloutViewCustomizerDelegate = calloutView into func mapView(_ mapView: MapViewPlus, calloutViewFor annotationView: AnnotationViewPlus) -> CalloutViewPlus method

Can you please try this way? Or you can share an example project that demonstrates the problem you are facing and I can try to help. @hemangshah

@okhanokbay
Copy link
Owner

Please re-open if there is anything else about this issue.

@hemangshah
Copy link
Author

Hi @okhanokbay, I still don't understand how CalloutViewPlusCenter is working? See if I want to show the CalloutView to self.view.frame.size.height - (tabbarHeight + margin + calloutViewHeight) then it should show at that place, right?

The values are as follows: tabbarHeight = 50.0, margin = 20.0, and calloutViewHeight = 100.0

@hemangshah
Copy link
Author

I noticed that it is not displaying (showing) the CalloutView based on the above value. But instead, it is displaying it based on the annotation position on the map. To understand this, I will add some screenshots here, FYR.

@okhanokbay
Copy link
Owner

Yes, it's altering the center of callout view related to annotation view, not related to view or map view itself. @hemangshah

@hemangshah
Copy link
Author

Ok, thanks for your quick reply @okhanokbay, Can I show my own view when annotation will be selected? Instead of showing a custom call out?

@okhanokbay
Copy link
Owner

okhanokbay commented Mar 14, 2018

You can return any UIView subclass (also must conform to CalloutViewPlus protocol) from calloutViewForAnnotationView

@hemangshah
Copy link
Author

@okhanokbay, sorry, I think, you have misunderstood this for that I have raised another issue which you can check. My own view means (not in a form of an annotation) instead I want it to be displayed in self.view.

@okhanokbay
Copy link
Owner

Is it #4 ? @hemangshah

@hemangshah
Copy link
Author

@okhanokbay, Yes!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants