2011-02-17 66 views
0

我在这里有一个关于定制注释的问题。这里是我如何显示引脚,但我希望在用户单击引脚时将图像插入到注释中。我怎样才能做到这一点?定制注释

- (void) showMarkingOnMap:(Service *) ser 
    { 
     if (!self.mapView.loaded) { 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"iPoly" 
                  message:@"Failed to load the map." 
                  delegate:self 
                cancelButtonTitle:@"Ok" 
                otherButtonTitles:nil, nil]; 
      [alert show]; 
      [alert release]; 

      return; 

     } 
     id<AGSLayerView> graphicsLayerView = [self.mapView.mapLayerViews objectForKey:@"GraphicsLayer"]; 
     AGSGraphicsLayer *graphicsLayer = (AGSGraphicsLayer*)graphicsLayerView.agsLayer; 
     [graphicsLayer removeAllGraphics]; 

     // Create a symbols png graphic 
     AGSPictureMarkerSymbol *genSymbol = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"pushpin.png"]; 
     ServiceInfoTemplate *infoTemplate = [[ServiceInfoTemplate alloc] init]; 
     AGSGraphic *genGraphic; 
     AGSPoint *genPt; 
     NSMutableDictionary *dic= [[NSMutableDictionary alloc] init]; 
     [dic setObject:[ser name] forKey:@"NAME"]; 
     if([ser.location isEqualToString: @"\n"] || (ser.location == nil)){ 
      [dic setObject:@"" forKey:@"DESC"]; 
     } else { 
      [dic setObject:[ser location] forKey:@"DESC"]; 
     } 
     genPt = [AGSPoint pointWithX:[[ser xcoordinate] floatValue] 
             y:[[ser ycoordinate] floatValue] 
         spatialReference:self.mapView.spatialReference]; 
     genGraphic = [[AGSGraphic alloc] initWithGeometry:genPt symbol:genSymbol attributes:dic infoTemplateDelegate:infoTemplate]; 
     [graphicsLayer addGraphic:genGraphic]; 

     [graphicsLayer dataChanged]; 

     [self.mapView zoomWithFactor:0.1 atAnchorPoint:genPt.cgPoint animated:NO]; 
     [self.mapView centerAtPoint:genPt animated:YES]; 

     //CGPoint *pt = CGPointMake([[ser ycoordinate] floatValue], [[ser xcoordinate] floatValue]); 


    } 

回答