|
@@ -37,7 +37,8 @@
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
@implementation LocationViewController {
|
|
@implementation LocationViewController {
|
|
|
- GMSMapView *mapView_;
|
|
|
|
|
|
|
+
|
|
|
|
|
+// GMSMapView *mapView_;
|
|
|
|
|
|
|
|
// 苹果原生的地图视图
|
|
// 苹果原生的地图视图
|
|
|
AMMapView *myMapView;
|
|
AMMapView *myMapView;
|
|
@@ -200,54 +201,54 @@
|
|
|
|
|
|
|
|
- (void)initGoogleMap {
|
|
- (void)initGoogleMap {
|
|
|
|
|
|
|
|
- [self updateLocation];
|
|
|
|
|
-
|
|
|
|
|
- GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:39.833333
|
|
|
|
|
- longitude:-98.3583333
|
|
|
|
|
- zoom:2.5
|
|
|
|
|
- bearing:0
|
|
|
|
|
- viewingAngle:0];
|
|
|
|
|
- mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
|
|
|
|
- mapView_.myLocationEnabled = YES;
|
|
|
|
|
- mapView_.delegate = self;
|
|
|
|
|
-
|
|
|
|
|
- mapView_.translatesAutoresizingMaskIntoConstraints = NO;
|
|
|
|
|
- [self.view addSubview:mapView_];
|
|
|
|
|
-
|
|
|
|
|
- NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:mapView_
|
|
|
|
|
- attribute:NSLayoutAttributeTop
|
|
|
|
|
- relatedBy:NSLayoutRelationEqual
|
|
|
|
|
- toItem:self.topLayoutGuide
|
|
|
|
|
- attribute:NSLayoutAttributeBottom
|
|
|
|
|
- multiplier:1.0
|
|
|
|
|
- constant:0];
|
|
|
|
|
- NSLayoutConstraint *left = [NSLayoutConstraint constraintWithItem:mapView_
|
|
|
|
|
- attribute:NSLayoutAttributeLeft
|
|
|
|
|
- relatedBy:NSLayoutRelationEqual
|
|
|
|
|
- toItem:self.view
|
|
|
|
|
- attribute:NSLayoutAttributeLeft
|
|
|
|
|
- multiplier:1.0
|
|
|
|
|
- constant:0];
|
|
|
|
|
- NSLayoutConstraint *bottom = [NSLayoutConstraint constraintWithItem:mapView_
|
|
|
|
|
- attribute:NSLayoutAttributeBottom
|
|
|
|
|
- relatedBy:NSLayoutRelationEqual
|
|
|
|
|
- toItem:self.bottomLayoutGuide
|
|
|
|
|
- attribute:NSLayoutAttributeTop
|
|
|
|
|
- multiplier:1.0
|
|
|
|
|
- constant:0];
|
|
|
|
|
- NSLayoutConstraint *right = [NSLayoutConstraint constraintWithItem:mapView_
|
|
|
|
|
- attribute:NSLayoutAttributeRight
|
|
|
|
|
- relatedBy:NSLayoutRelationEqual
|
|
|
|
|
- toItem:self.view
|
|
|
|
|
- attribute:NSLayoutAttributeRight
|
|
|
|
|
- multiplier:1.0
|
|
|
|
|
- constant:0];
|
|
|
|
|
- [self.view addConstraints:@[top,left,bottom,right]];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- [self addLocation];
|
|
|
|
|
|
|
+// [self updateLocation];
|
|
|
|
|
+//
|
|
|
|
|
+// GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:39.833333
|
|
|
|
|
+// longitude:-98.3583333
|
|
|
|
|
+// zoom:2.5
|
|
|
|
|
+// bearing:0
|
|
|
|
|
+// viewingAngle:0];
|
|
|
|
|
+// mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
|
|
|
|
+// mapView_.myLocationEnabled = YES;
|
|
|
|
|
+// mapView_.delegate = self;
|
|
|
|
|
+//
|
|
|
|
|
+// mapView_.translatesAutoresizingMaskIntoConstraints = NO;
|
|
|
|
|
+// [self.view addSubview:mapView_];
|
|
|
|
|
+//
|
|
|
|
|
+// NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:mapView_
|
|
|
|
|
+// attribute:NSLayoutAttributeTop
|
|
|
|
|
+// relatedBy:NSLayoutRelationEqual
|
|
|
|
|
+// toItem:self.topLayoutGuide
|
|
|
|
|
+// attribute:NSLayoutAttributeBottom
|
|
|
|
|
+// multiplier:1.0
|
|
|
|
|
+// constant:0];
|
|
|
|
|
+// NSLayoutConstraint *left = [NSLayoutConstraint constraintWithItem:mapView_
|
|
|
|
|
+// attribute:NSLayoutAttributeLeft
|
|
|
|
|
+// relatedBy:NSLayoutRelationEqual
|
|
|
|
|
+// toItem:self.view
|
|
|
|
|
+// attribute:NSLayoutAttributeLeft
|
|
|
|
|
+// multiplier:1.0
|
|
|
|
|
+// constant:0];
|
|
|
|
|
+// NSLayoutConstraint *bottom = [NSLayoutConstraint constraintWithItem:mapView_
|
|
|
|
|
+// attribute:NSLayoutAttributeBottom
|
|
|
|
|
+// relatedBy:NSLayoutRelationEqual
|
|
|
|
|
+// toItem:self.bottomLayoutGuide
|
|
|
|
|
+// attribute:NSLayoutAttributeTop
|
|
|
|
|
+// multiplier:1.0
|
|
|
|
|
+// constant:0];
|
|
|
|
|
+// NSLayoutConstraint *right = [NSLayoutConstraint constraintWithItem:mapView_
|
|
|
|
|
+// attribute:NSLayoutAttributeRight
|
|
|
|
|
+// relatedBy:NSLayoutRelationEqual
|
|
|
|
|
+// toItem:self.view
|
|
|
|
|
+// attribute:NSLayoutAttributeRight
|
|
|
|
|
+// multiplier:1.0
|
|
|
|
|
+// constant:0];
|
|
|
|
|
+// [self.view addConstraints:@[top,left,bottom,right]];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// [self addLocation];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)mapView:(GMSMapView *)mapView
|
|
- (void)mapView:(GMSMapView *)mapView
|
|
@@ -406,59 +407,59 @@ didTapInfoWindowOfMarker:(GMSMarker *)marker
|
|
|
-(void) addLocation
|
|
-(void) addLocation
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- [mapView_ clear];
|
|
|
|
|
- self.Locations = [ApexMobileDB get_Location];
|
|
|
|
|
- UIImage *image;
|
|
|
|
|
- image = [UIImage imageNamed:@"ic_marker.png"];
|
|
|
|
|
- for (int i = 0; i < self.Locations.count ; i ++)
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- NSDictionary* location = self.Locations[i];
|
|
|
|
|
- NSString* area = [location valueForKey:@"area"];
|
|
|
|
|
- NSString* company = [location valueForKey:@"company"];
|
|
|
|
|
- NSString* city = [location valueForKey:@"city"];
|
|
|
|
|
- double longitude = [[location valueForKey:@"longitude"] doubleValue];
|
|
|
|
|
- double latitude = [[location valueForKey:@"latitude"] doubleValue];
|
|
|
|
|
- // NSString* address = [location valueForKeyPath:@"address"];
|
|
|
|
|
- // NSString* telephone = [location valueForKeyPath:@"telephone"];
|
|
|
|
|
- // NSString* fax = [location valueForKeyPath:@"fax"];
|
|
|
|
|
- // NSString* contact = [location valueForKeyPath:@"contact"];
|
|
|
|
|
- // NSString* email = [location valueForKeyPath:@"email"];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // NSString *markertext = parts[i];
|
|
|
|
|
- // NSString *city = parts[i + 1];
|
|
|
|
|
- // NSString *postext = parts[i + 2];
|
|
|
|
|
- // NSArray *point = [postext componentsSeparatedByString:NSLocalizedString(@",", nil)];//postext.split(",");
|
|
|
|
|
- //
|
|
|
|
|
- // NSString *address = parts[i+3];
|
|
|
|
|
- // NSArray *tel = parts[i+4];
|
|
|
|
|
- // NSArray *fax = parts[i+5];
|
|
|
|
|
- // NSArray *contact = parts[i+6];
|
|
|
|
|
- // NSArray *email = parts[i+7];
|
|
|
|
|
-
|
|
|
|
|
- // NSMutableDictionary* params = [[NSMutableDictionary alloc]init];
|
|
|
|
|
- // [params setObject:markertext forKey:@"name"];
|
|
|
|
|
- // [params setObject:address forKey:@"addr"];
|
|
|
|
|
- // [params setObject:telephone forKey:@"tel"];
|
|
|
|
|
- // [params setObject:fax forKey:@"fax"];
|
|
|
|
|
- // [params setObject:contact forKey:@"contact"];
|
|
|
|
|
- // [params setObject:email forKey:@"email"];
|
|
|
|
|
-
|
|
|
|
|
- // // Creates a marker in the center of the map.
|
|
|
|
|
- GMSMarker *marker = [[GMSMarker alloc] init];
|
|
|
|
|
- marker.position = CLLocationCoordinate2DMake(latitude,longitude);
|
|
|
|
|
- marker.title = company;
|
|
|
|
|
- // NSString* snippet = [city stringByAppendingString:@"\n Click for more detail"];
|
|
|
|
|
- marker.snippet = [[NSString stringWithFormat:@"%@\n%@",city,area] stringByAppendingString:NSLocalizedString(@"ask_click", nil)];
|
|
|
|
|
- marker.map = mapView_;
|
|
|
|
|
- marker.userData = location;
|
|
|
|
|
- marker.icon = image;
|
|
|
|
|
-
|
|
|
|
|
- DebugLog(@"create marker title:%@ snippet:%@",marker.title,marker.snippet);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// [mapView_ clear];
|
|
|
|
|
+// self.Locations = [ApexMobileDB get_Location];
|
|
|
|
|
+// UIImage *image;
|
|
|
|
|
+// image = [UIImage imageNamed:@"ic_marker.png"];
|
|
|
|
|
+// for (int i = 0; i < self.Locations.count ; i ++)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// NSDictionary* location = self.Locations[i];
|
|
|
|
|
+// NSString* area = [location valueForKey:@"area"];
|
|
|
|
|
+// NSString* company = [location valueForKey:@"company"];
|
|
|
|
|
+// NSString* city = [location valueForKey:@"city"];
|
|
|
|
|
+// double longitude = [[location valueForKey:@"longitude"] doubleValue];
|
|
|
|
|
+// double latitude = [[location valueForKey:@"latitude"] doubleValue];
|
|
|
|
|
+// // NSString* address = [location valueForKeyPath:@"address"];
|
|
|
|
|
+// // NSString* telephone = [location valueForKeyPath:@"telephone"];
|
|
|
|
|
+// // NSString* fax = [location valueForKeyPath:@"fax"];
|
|
|
|
|
+// // NSString* contact = [location valueForKeyPath:@"contact"];
|
|
|
|
|
+// // NSString* email = [location valueForKeyPath:@"email"];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// // NSString *markertext = parts[i];
|
|
|
|
|
+// // NSString *city = parts[i + 1];
|
|
|
|
|
+// // NSString *postext = parts[i + 2];
|
|
|
|
|
+// // NSArray *point = [postext componentsSeparatedByString:NSLocalizedString(@",", nil)];//postext.split(",");
|
|
|
|
|
+// //
|
|
|
|
|
+// // NSString *address = parts[i+3];
|
|
|
|
|
+// // NSArray *tel = parts[i+4];
|
|
|
|
|
+// // NSArray *fax = parts[i+5];
|
|
|
|
|
+// // NSArray *contact = parts[i+6];
|
|
|
|
|
+// // NSArray *email = parts[i+7];
|
|
|
|
|
+//
|
|
|
|
|
+// // NSMutableDictionary* params = [[NSMutableDictionary alloc]init];
|
|
|
|
|
+// // [params setObject:markertext forKey:@"name"];
|
|
|
|
|
+// // [params setObject:address forKey:@"addr"];
|
|
|
|
|
+// // [params setObject:telephone forKey:@"tel"];
|
|
|
|
|
+// // [params setObject:fax forKey:@"fax"];
|
|
|
|
|
+// // [params setObject:contact forKey:@"contact"];
|
|
|
|
|
+// // [params setObject:email forKey:@"email"];
|
|
|
|
|
+//
|
|
|
|
|
+// // // Creates a marker in the center of the map.
|
|
|
|
|
+// GMSMarker *marker = [[GMSMarker alloc] init];
|
|
|
|
|
+// marker.position = CLLocationCoordinate2DMake(latitude,longitude);
|
|
|
|
|
+// marker.title = company;
|
|
|
|
|
+// // NSString* snippet = [city stringByAppendingString:@"\n Click for more detail"];
|
|
|
|
|
+// marker.snippet = [[NSString stringWithFormat:@"%@\n%@",city,area] stringByAppendingString:NSLocalizedString(@"ask_click", nil)];
|
|
|
|
|
+// marker.map = mapView_;
|
|
|
|
|
+// marker.userData = location;
|
|
|
|
|
+// marker.icon = image;
|
|
|
|
|
+//
|
|
|
|
|
+// DebugLog(@"create marker title:%@ snippet:%@",marker.title,marker.snippet);
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
}
|
|
}
|
|
|
-(void) updateLocation
|
|
-(void) updateLocation
|
|
|
{
|
|
{
|