facebookarchive / AsyncDisplayKit

Smooth asynchronous user interfaces for iOS apps.
http://asyncdisplaykit.org
Other
13.4k stars 2.2k forks source link

How can i use custom mapview in ASDK? #3291

Closed DGLY closed 7 years ago

DGLY commented 7 years ago

I want to use MAMapview in the project ,but I found only supports the native maps,so how can I solve this problems

haashem commented 7 years ago

please post your issue in Texture GitHub repository: https://github.com/TextureGroup/Texture

appleguy commented 7 years ago

@DGLY You can wrap any UIView by using [[ASDisplayNode alloc] initWithViewBlock:^{ // configure and return custom view }];

You can even set customNode.style parameters to control layout behavior and add these nodes to ASLayoutSpec trees in layoutSpecThatFits.

Feel free to ask further questions on the Texture repository or join the Slack channel (you'll get better responses there).

haashem commented 7 years ago

this how I do in init method of my custom node:

mapNode = ASDisplayNode(viewBlock: { () -> UIView in
            let location = CLLocationCoordinate2D(latitude: 35.727541, longitude: 51.488807)
            let camera = GMSCameraPosition.camera(withLatitude: location.latitude, longitude: location.longitude, zoom: 14)
            let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
            mapView.settings.setAllGesturesEnabled(false)

            // add event location on the map
            let marker = GMSMarker()

            marker.position = CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude)
            marker.map = mapView
            let eventMarker = VenueMarker()
            eventMarker.tintColor = .secondaryColor
            marker.iconView = eventMarker
            return mapView
        })
DGLY commented 7 years ago

This method is really can resolve the custom map view,but i don't konw how to use this custom node add more annotation,i just konw use ASMapnode to do this.