JXPlaceMarkModel.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // JXPlaceMarkModel.m
  3. // shiku_im
  4. //
  5. // Created by MacZ on 16/8/31.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JXPlaceMarkModel.h"
  9. #import <MapKit/MapKit.h>
  10. #import <BaiduMapAPI_Search/BMKPoiSearchType.h>
  11. @implementation JXPlaceMarkModel
  12. + (JXPlaceMarkModel *)modelByCLPlacemark:(CLPlacemark *)placeMark{
  13. JXPlaceMarkModel *model = [[JXPlaceMarkModel alloc] init];
  14. model.longitude = placeMark.location.coordinate.longitude;
  15. model.latitude = placeMark.location.coordinate.latitude;
  16. model.placeName = placeMark.thoroughfare;
  17. model.address = [placeMark.name stringByReplacingOccurrencesOfString:placeMark.country withString:@""]; //去掉国家名
  18. model.address = [model.address stringByReplacingOccurrencesOfString:placeMark.administrativeArea withString:@""]; //去掉省份名
  19. return model;
  20. }
  21. + (JXPlaceMarkModel *)modelByMKMapItem:(MKMapItem *)mapItem{
  22. JXPlaceMarkModel *model = [[JXPlaceMarkModel alloc] init];
  23. model.longitude = mapItem.placemark.location.coordinate.longitude;
  24. model.latitude = mapItem.placemark.location.coordinate.latitude;
  25. model.placeName = mapItem.name;
  26. model.address = mapItem.placemark.thoroughfare;
  27. return model;
  28. }
  29. + (JXPlaceMarkModel *)modelByBMKPoiInfo:(BMKPoiInfo *)bmkPoiInfo{
  30. JXPlaceMarkModel *model = [[JXPlaceMarkModel alloc] init];
  31. model.longitude = bmkPoiInfo.pt.longitude;
  32. model.latitude = bmkPoiInfo.pt.latitude;
  33. model.placeName = bmkPoiInfo.name;
  34. model.address = bmkPoiInfo.address;
  35. model.name = bmkPoiInfo.name;
  36. model.city = bmkPoiInfo.city;
  37. return model;
  38. }
  39. -(NSString *)description{
  40. return [NSString stringWithFormat:@"name:%@,经纬度:(%f,%f),建筑名:%@,地址:%@,城市:%@",self.name,self.longitude,self.latitude,self.placeName,self.address,self.city];
  41. }
  42. @end