IOS_21 Group buy _ map function, ios_21 Group buy Map

Source: Internet
Author: User

IOS_21 Group buy _ map function, ios_21 Group buy Map

Finally:




The "back to user" button in the lower right corner:




MapController controller,

Is the Controller corresponding to the Map button on the dock on the left of the master controller,

Inherited from ShowDealDetailController,

Therefore, the system automatically displays the Group Buying details controller.

//// MapController. h // handsome guy _ buy /// Created by beyond on 14-8-14. // Copyright (c) 2014 com. beyond. all rights reserved. // The Controller corresponding to the Map button on the dock, inherited from ShowDealDetailController. h controller, which automatically displays the Group Buying details controller # import "ShowDealDetailController. h "@ interface MapController: ShowDealDetailController @ end


//// MapController. m // handsome _ buy /// Created by beyond on 14-8-14. // Copyright (c) 2014 com. beyond. all rights reserved. // The Controller corresponding to the Map button on the dock, inherited from ShowDealDetailController. h controller, which automatically displays the Group Buying details controller # import "MapController. h "# import <MapKit/MapKit. h> # import "DealRequestTool. h "# import" MetaDataTool ool. h "# import" LocationTool. h "// The Member has latitude and longitude coordinates # import" City. h "// a merchant model # import" Business. h "# import" Deal. h "// a pin model, large # Import "MyAnnotation. h "// cross-Longitude and latitude # define kSpan MKCoordinateSpanMake (0.018404, 0.031468) @ interface MapController () <MKMapViewDelegate> {MKMapView * _ mapView; NSMutableArray * _ showingDeals ;} @ end @ implementation MapController-(void) viewDidLoad {[super viewDidLoad]; self. title = @ "map"; // 0. notification of listener positioning completed ..... there is a problem with kAddAllNotes (dataChange) // 1. add map MKMapView * mapView = [[MKMapView alloc] init WithFrame: self. view. bounds]; mapView. autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; // display the user's position in mapView. showsUserLocation = YES; // sets the proxy mapView. delegate = self; [self. view addSubview: mapView]; // 2. initialize the array _ showingDeals = [NSMutableArray array]; // 3. click [self addBackToUserLocationBtn];}-(void) addBackToUserLocationBtn {// 3. UIButton * bac KUserBtn = [UIButton buttonWithType: bytes]; CGSize imgSize = [backUserBtn setBtnBgImgForNormal: @ "weight" highlightedName: @ "weight"]; CGFloat w = imgSize. width; CGFloat h = imgSize. height; CGFloat margin = 20; CGFloat x = self. view. frame. size. width-w-margin; CGFloat y = self. view. frame. size. height-h-margin; // The button is in the bottom right corner, so the left margin and top margin are automatically scaled backUserBtn. frame = CGRectMake (x, y, w, h); backUserBtn. autoresizingMask = custom | UIViewAutoresizingFlexibleTopMargin; [backUserBtn addTarget: self action: @ selector (backToUserLocationBtnClicked) forControlEvents: UIControlEventTouchUpInside]; [self. view addSubview: backUserBtn];} // The user center button is clicked.-(void) backToUserLocationBtnClicked {// mapView stores the user's location information (The annotation representing the us Er's location) CLLocationCoordinate2D center = _ mapView. userLocation. location. coordinate; MKCoordinateRegion region = MKCoordinateRegionMake (center, kSpan); // set the center [_ mapView setRegion: region animated: YES];} # proxy method of pragma mark-mapView # pragma mark will be called when it locates the user's location (the call frequency is quite high) --- 2-(void) mapView :( MKMapView *) mapView didUpdateUserLocation :( MKUserLocation *) userLocation {// just let it locate the user coordinate for the first time if (_ mapView) retur N; // 1. CLLocationCoordinate2D center = userLocation. location. coordinate; // 2. after the center point is determined, determine the span (range) // MKCoordinateSpan span = MKCoordinateSpanMake (0.018404, 0.031468); // 3. based on the center point and span, the region MKCoordinateRegion region = MKCoordinateRegionMake (center, kSpan) is determined. // 4. display mapView to the specified region [mapView setRegion: region animated: YES]; _ mapView = mapView; // set the Center Coordinate to the user's coordinate... // [mapView setCenterCoordi Nate: userLocation. location. coordinate animated: YES];} # pragma mark: drag the map (the area displayed on the map changes) and call-(void) mapView :( MKMapView *) mapView regionWillChangeAnimated :( BOOL) animated {// 1. the central location of the current map area is CLLocationCoordinate2D pos = mapView. region. center; // calculate the city name based on the coordinates of the center. // 2. use the tool class to send a request to the server [[DealRequestTool sharedDealRequestTool] dealsRequestWithPos: pos success: ^ (NSArray * deals, int total_count) {// traverse the returned deals Array And compare it with the deals array saved by the current controller. If this deal is already displayed, the continue skips and for (Deal * d in deals) {// already displayed. skip this step to prevent the pin shadow from deepening if ([_ showingDeals containsObject: d]) continue; // if the returned deal is never displayed, add the group members to the member array first, and then display the group members: commodity area one by one with a pin on the mapView [_ showingDeals addObject: d]; // traverses the array of merchant objects for (Business * B in d. businesses) {// a merchant corresponds to a pin model, that is, a data source, providing data for the Annotation View. // Annotation is a model used to mark coordinates on the map // implement the mapView of the proxy: viewForAnn Otation: method. The Annotation View corresponding to each Annotation is returned. MyAnnotation * anno = [[MyAnnotation alloc] init]; anno. business = B; anno. deal = d; anno. coordinate = CLLocationCoordinate2DMake (B. latitude, B. longpolling); // important ~~~ Provide data for mapView. The following method is displayed: mapView: viewForAnnotation: [mapView addAnnotation: anno] ;}} error: ^ (NSError * error) {log (@ "error --- % @", error) ;}] ;}# proxy method of pragma mark-mapView // similar to cell For Row, providing view For each annotation, the custom Annotation model-(MKAnnotationView *) mapView :( MKMapView *) mapView viewForAnnotation :( MyAnnotation *) annotation {if (! [Annotation isKindOfClass: [MyAnnotation class]) return nil; // 1. retrieve the pin view static NSString * ID = @ "MKAnnotationView" from the cache pool; MKAnnotationView * annoView = [mapView dequeueReusableAnnotationViewWithIdentifier: ID]; // 2. the cache pool does not have a circular pin view if (annoView = nil) {// The MKPinAnnotationView subclass should be used here. When constructing an annotationView, the data source model annotation annoView = [[MKPinAnnotationView alloc] initWithAnnotation: annotation must be provided ReuseIdentifier: ID];} // 3. set the view PIN information to provide a unique data source model annoView. annotation = annotation; // 4. set the image annoView. image = [UIImage imageNamed: annotation. icon]; return annoView;} # pragma mark clicked the pin-(void) mapView :( MKMapView *) mapView didSelectAnnotationView :( MKAnnotationView *) view {// 0. if it is a pin that comes with the system, it will be returned directly... if (! [View. annotation isKindOfClass: [MyAnnotation class]) {return;} // 1. call the method of the parent class to display the details controller and provide the data source MyAnnotation * anno = view. annotation; [self showDetail: anno. deal]; // 2. center the selected pin (becomes the center point) [mapView setCenterCoordinate: anno. coordinate animated: YES]; // 3. make the view area have some shadow effect view. layer. shadowColor = [UIColor blueColor]. CGColor; view. layer. shadowOpacity = 1; view. layer. shadowRadius = 10;} # pragma mark-Refresh webView when the monitored city changes. // 0. listener-(void) dataChange {// 1. city * city = [MetaDataTool ool sharedMetaDataTool ool]. currentCity; CLGeocoder * geo = [[CLGeocoder alloc] init]; // global search for a city [geo geocodeAddressString: city. name completionHandler: ^ (NSArray * placemarks, NSError * error) {// location. After resolution, you can provide the latitude and longitude CLPlacemark * place = placemarks [0]; // 1. CLLocationCoordinate2D center = place. location. coordinate; city. position = place. location. coordinate; // important. Remember the city tool because the city name and latitude [LocationTool sharedLocationTool] are also used when sending the request. locationCity = city; // 2. after determining the center point, determine the span (range) // 3. based on the center point and span, the region MKCoordinateRegion region = MKCoordinateRegionMake (center, kSpan) is determined. // 4. display mapView to the specified region [_ mapView setRegion: region animated: YES];} @ end












Is it expensive to create a website similar to a group buying website? It can basically include the functions of group buying websites, but it can also contain some map positioning functions.

Hello, generally, shopping websites have these features. Our company used to do this in Shengshi huacai. We feel that we can do it ourselves and the price is moderate.

How can I query group buying information on a search map?

Dear friend, click "layer" in the upper left corner of the map and select "group buying layer"
Click a specific item in the group buying layer to view detailed information about the group buying.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.