Search Results

Search found 271 results on 11 pages for 'mapview'.

Page 6/11 | < Previous Page | 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • adding onTap method on path direction between 2 point

    - by idham
    I have a problem in my Android application I have a path direction on my application and I want to add an onTap method for the path, so if I touch that path my application will display information with alert dialog. This my activity code: hasilrute hr = new hasilrute(); for (int k = 0;k < hr.r2.size(); k++){ String angkot = hr.r2.get(i).angkot; Cursor c = db.getLatLong(hasilrute.a); Cursor cc = db.getLatLong(hasilrute.b); String x = (c.getString(3)+","+c.getString(2)); String xx = (cc.getString(3)+","+cc.getString(2)); String pairs[] = getDirectionData(x, xx); String[] lnglat = pairs[0].split(","); GeoPoint point = new GeoPoint((int) (Double.parseDouble(lnglat[1]) *1E6),(int)(Double.parseDouble(lnglat[0]) * 1E6)); GeoPoint gp1; GeoPoint gp2 = point; for (int j = 1;j < pairs.length; j++){ lnglat = pairs[j].split(","); gp1 = gp2; gp2 = new GeoPoint((int) (Double.parseDouble(lnglat[1]) *1E6),(int) (Double.parseDouble(lnglat[0]) * 1E6)); mapView.getOverlays().add(new jalur(gp1, gp2,angkot)); } } and it's my jalur.java code public class jalur extends Overlay { private GeoPoint gp1; private GeoPoint gp2; private String angkot; private Context mContext; public jalur(GeoPoint gp1, GeoPoint gp2, String angkot){ this.gp1 = gp1; this.gp2 = gp2; this.angkot = angkot; } @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when){ Projection projection = mapView.getProjection(); if (shadow == false){ if (angkot.equals("Cimahi-Leuwipanjang")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(118,171,127)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimahi-Cangkorah")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(67,204,255)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimindi-Cipatik")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(42,82,0)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Jalan Kaki")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(0,0,0)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimahi-Padalarang")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(229,66,66)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); } if (angkot.equals("Pasantren-Sarijadi")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(4,39,255)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimahi-Parongpong")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(141,0,200)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimahi-Cibeber")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(255,246,0)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimahi-Cimindi")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(220,145,251)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimahi-Contong")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(242,138,138)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimahi-Soreang")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(0,255,78)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); }if (angkot.equals("Cimahi-Batujajar")){ Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); projection.toPixels(gp1,point); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setColor(Color.rgb(137,217,51)); paint.setStrokeWidth(2); canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint); } } return super.draw(canvas, mapView, shadow, when); } @Override public void draw(Canvas canvas, MapView mapView, boolean shadow){ super.draw(canvas, mapView, shadow); } } thanks for your attention :)

    Read the article

  • Android: who can help me with setting up this google maps class please??

    - by Capsud
    Hi, Firstly this has turned out to be quite a long post so please bear with me as its not too difficult but you may need to clarify something with me if i haven't explained it correctly. So with some help the other day from guys on this forum, i managed to partially set up my 'mapClass' class, but i'm having trouble with it and its not running correctly so i would like some help if possible. I will post the code below so you can see. What Ive got is a 'Dundrum' class which sets up the listView for an array of items. Then ive got a 'dundrumSelector' class which I use to set up the setOnClickListener() methods on the listItems and link them to their correct views. DundrumSelector class.. public static final int BUTTON1 = R.id.anandaAddressButton; public static final int BUTTON2 = R.id.bramblesCafeAddressButton; public static final int BUTTON3 = R.id.brannigansAddressButton; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); int position = getIntent().getExtras().getInt("position"); if(position == 0){ setContentView(R.layout.ananda); }; if(position == 1){ setContentView(R.layout.bramblescafe); }; if(position == 2){ setContentView(R.layout.brannigans); Button anandabutton = (Button) findViewById(R.id.anandaAddressButton); anandabutton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(view.getContext(),MapClass.class); myIntent.putExtra("button", BUTTON1); startActivityForResult(myIntent,0); } }); Button bramblesbutton = (Button) findViewById(R.id.bramblesCafeAddressButton); bramblesbutton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(view.getContext(),MapClass.class); myIntent.putExtra("button", BUTTON2); startActivityForResult(myIntent, 0); } }); etc etc.... Then what i did was set up static ints to represent the buttons which you can see at the top of this class, the reason for this is because in my mapClass activity I just want to have one method, because the only thing that is varying is the coordinates to each location. ie. i dont want to have 100+ map classes essentially doing the same thing other than different coordinates into the method. So my map class is as follows... case DundrumSelector.BUTTON1: handleCoordinates("53.288719","-6.241179"); break; case DundrumSelector.BUTTON2: handleCoordinates("53.288719","-6.241179"); break; case DundrumSelector.BUTTON3: handleCoordinates("53.288719","-6.241179"); break; } } private void handleCoordinates(String l, String b){ mapView = (MapView) findViewById(R.id.mapView); LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom); View zoomView = mapView.getZoomControls(); zoomLayout.addView(zoomView, new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mapView.displayZoomControls(true); mc = mapView.getController(); String coordinates[] = {l, b}; double lat = Double.parseDouble(coordinates[0]); double lng = Double.parseDouble(coordinates[1]); p = new GeoPoint( (int) (lat*1E6), (int) (lng*1E6)); mc.animateTo(p); mc.setZoom(17); mapView.invalidate(); } Now this is where my problem is. The onClick() events don't even work from the listView to get into the correct views. I have to comment out the methods in 'DundrumSelector' before I can get into their views. And this is what I dont understand, firstly why wont the onClick() events work, because its not even on that next view where the map is. I know this is a very long post and it might be quite confusing so let me know if you want any clarification.. Just to recap, what i'm trying to do is just have one class that sets up the map coordinates, like what i'm trying to do in my 'mapClass'. Please can someone help or suggest another way of doing this! Thanks alot everyone for reading this.

    Read the article

  • Objective-J Cappuccino want a list of buttons on main menu, when I click the panel refreshes with UI

    - by Setori
    Dear all, I am new to objective-j/c and cappuccino not really sure how this all fits together. The code below is taken from http://github.com/jfahrenkrug/CappuccinoLocations1 What I need to do is: I need a landing main menu which is a CPView called ie MainView with five or so buttons, when you click on the LocationButton on MainView is replaces MainView by with LocationView, which displays the contents of jfahrenkrug's work. A similar effect will happen with each other button. What is the correct Objective-c/j way of handling this approach? @import <Foundation/CPObject.j> @import "src/Location/LocationView.j" @implementation AppController : CPObject { LocationView locationView; } - (void)applicationDidFinishLaunching:(CPNotification)aNotification { var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], mainContentView = [theWindow locationView], bounds = [locationView bounds]; [mainContentView setBackgroundColor:[CPColor colorWithRed:212.0 /255.0 green:221.0/ 255.0 blue:230.0/255.0 alpha:1.0]]; locationView = [[LocationView alloc] initWithFrame:CGRectMake(0,0,920.0,590.0)]; [locationView setCenter:[mainContentView center]]; [locationView setBackgroundColor:[CPColor whiteColor]] [locationView setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; var shadow = [[CPShadowView alloc] initWithFrame:CGRectMakeZero()]; [shadow setFrameForContentFrame:[locationView frame]]; [shadow setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; [mainContentView addSubview:shadow]; [mainContentView addSubview:locationView]; [theWindow orderFront:self]; } Now we have the locationView.j @import "LocationsController.j" @import "LocationListView.j" @import "MapController.j" @import "LocationsToolbar.j" @import "LocationDetailView.j" @import "LocationDetailController.j" @implementation LocationView : CPView { LocationsController locationsController; LocationListView locationListView; MapController mapController; MKMapView mapView; CPTextField coordinatesLabel; LocationsToolbar locationsToolbar; LocationDetailView locationDetailView; LocationDetailController locationDetailController; CPTextField searchField; // id delegate @accessors; } - (id)initWithFrame:(CGRect)aFrame { self = [super initWithFrame:aFrame]; if(self){ locationsController = [[LocationsController alloc] init]; [locationsController loadExampleLocations]; locationListView = [[LocationListView alloc] initWithFrame:CGRectMake(0.0,0.0,226.0,400.0)]; [locationListView setContent:[locationsController locations]]; [locationListView setDelegate:locationsController]; [locationsController setLocationListView:locationListView]; var locationScrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(10.0,65.0,243.0,400.0)]; [locationScrollView setDocumentView:locationListView]; [locationScrollView setAutohidesScrollers:YES]; [[locationScrollView self] setBackgroundColor:[CPColor whiteColor]]; [self addSubview:locationScrollView]; mapController = [[MapController alloc] init]; mapView = [[MKMapView alloc] initWithFrame:CGRectMake(510,65,400,400) apiKey:'' ]; [mapView setDelegate:self]; mapController.mapView = mapView; [self addSubview:mapView]; coordinatesLabel = [[CPTextField alloc] initWithFrame:CGRectMake(510,465,200,35)]; [coordinatesLabel setTextColor:[CPColor colorWithHexString:@"009900"]]; [coordinatesLabel setFont:[CPFont systemFontOfSize:14.0]]; [coordinatesLabel setEditable:NO]; [coordinatesLabel setStringValue:@"-/-"]; [mapController setCoordinatesLabel:coordinatesLabel]; [self addSubview:coordinatesLabel]; locationsToolbar = [[LocationsToolbar alloc] initWithFrame:CGRectMake(10.0,467.0,226.0,25.0)]; [locationsToolbar setDelegate:locationsController]; [self addSubview:locationsToolbar]; locationDetailController = [[LocationDetailController alloc] init]; locationDetailController.mapController = mapController; locationsController.locationDetailController = locationDetailController; [mapController setDelegate:locationDetailController]; locationDetailView = [[LocationDetailView alloc] initWithFrame:CGRectMake(510,490,400,90)]; [locationDetailView setDelegate:locationDetailController]; [locationDetailController setLocationDetailView:locationDetailView]; [self addSubview:locationDetailView]; searchField = [CPTextField roundedTextFieldWithStringValue:@"" placeholder:@"Location" width:200.0]; [searchField setFrameOrigin:CGPointMake(510.0,35.0)]; [searchField setDelegate:self]; [self addSubview:searchField]; var searchButton = [[CPButton alloc] initWithFrame:CGRectMake(710.0,37.0,60.0,24.0)]; [searchButton setTitle:"Search"]; [searchButton setTarget:self]; [searchButton setAction:@selector(searchLocation)]; [self addSubview:searchButton]; } return self; }

    Read the article

  • MKMapView memory usage grows out of control with setRegion: calls

    - by Kurt
    Hi, I have a single MKMapView instance that I have programmatically added to a UIView. As part of the UI, the user can cycle through a list of addresses and the map view is updated to show the correct map for each address as the user goes through them. I create the map view once, and simply change what it displays with setRegion:animated:. The problem is that each time the map is changed to show a new address, the memory usage of my program increases by 200K-500K (as reported by Memory Monitor in Instruments). According to Object Allocations, it appears that a lot of 1.0K Mallocs are happening each time, and the Extended Detail pane for these 1.0K allocations shows that the Responsible Caller is convert_image_data and the Extended Detail pane shows that this is the result of [MKMapTileView drawLayer:inContext:]. So, seems likely to me that the memory usage is due to MKMapView not freeing memory it uses to redraw the map each time. In fact, when I don't display the map at all (by not even adding it as a subview of my main UIView) but still cycle through the addresses (which changes various UILabels and other displayed info) the memory usage for the app does NOT increase. If I add the map view but never update it with setRegion:, the memory also does NOT increase when changing to a new address. One more bit of info: if I go to a new address (and therefore ask the map to display the new address) the memory jumps as described above. However, if I go back to an address that was already displayed, the memory does not jump when the map redraws with the old address. Also, this happens on iPad (real device) with 3.2 and on iPhone (again, real device) with 3.1.2. Here's how I initialize the MKMapView (I only do this once): CGRect mapFrame; mapFrame.origin.y = 460; // yes, magic numbers. just for testing. mapFrame.origin.x = 0; mapFrame.size.height = 500; mapFrame.size.width = 768; mapView = [[MKMapView alloc] initWithFrame:mapFrame]; mapView.delegate = self; [self.view insertSubview:mapView atIndex:0]; And in response to the user selecting an address, I set the map like so: MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta=kStreetMapSpan; // 0.003 span.longitudeDelta=kStreetMapSpan; // 0.003 region.center = address.coords; // coords is CLLocationCoordinate2D region.span = span; mapView.region.span = span; [mapView setRegion:region animated:NO]; Any thoughts? I've scoured the net but haven't seen mention of this problem, and I've reached the limits of my Instruments knowledge. Thanks for any ideas.

    Read the article

  • Uncenter MkMapView

    - by Makinitez21
    I am trying to "uncenter" the map view and remove all annotations. the reason for this is that the mapView will be used by different view controllers to display different annotations and locations. What's happening now is that i am using the "remove annotations" method and i removes them, but the map stays centered on the spot and thus when the new annotations come in, it does not move. Is there a way to reset the region and if so, what value do i reset it to. I tried nil, zero and some calculated value but "core animation" says they are all invalid. how do i get that to zoom out and back in on my new annotations? here is some code -(void)recenterMap { NSArray *coordinates = [_mapView valueForKeyPath:@"annotations.coordinate"]; CLLocationCoordinate2D maxCoord = {-90.0f, -180.0f}; CLLocationCoordinate2D minCoord = {90.0f, 180.0f}; //NSLog(@"%@", [coordinates description]); for (NSValue *value in coordinates) { CLLocationCoordinate2D coord = {0.0f, 0.0f}; [value getValue: &coord]; if(coord.longitude > maxCoord.longitude) { maxCoord.longitude = coord.longitude; } if(coord.latitude > maxCoord.latitude){ maxCoord.latitude = coord.latitude; } if(coord.longitude < minCoord.longitude){ minCoord.longitude = coord.longitude; } if(coord.latitude < minCoord.latitude){ minCoord.latitude = coord.latitude; } } MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}}; region.center.longitude = (minCoord.longitude + maxCoord.longitude) / 2.0; region.center.latitude = (minCoord.latitude + maxCoord.latitude) / 2.0; region.span.longitudeDelta = maxCoord.longitude - minCoord.longitude; region.span.latitudeDelta = maxCoord.latitude - minCoord.latitude; [_mapView setRegion: region animated: YES]; } Thats the recenter methos i'm using - (MKAnnotationView *)mapView: (MKMapView *)mapView viewForAnnotation: (id <MKAnnotation>)annotation{ MKAnnotationView *view = nil; if(annotation != mapView.userLocation){ Annotation *schoolAnn = (Annotation*)annotation; view = [self.mapView dequeueReusableAnnotationViewWithIdentifier:@"schoolLoc"]; if(nil == view){ view = [[[MKPinAnnotationView alloc] initWithAnnotation:schoolAnn reuseIdentifier:@"schoolLoc"]autorelease]; } [(MKPinAnnotationView *)view setAnimatesDrop:YES]; [view setCanShowCallout:YES]; } else { [self recenterMap]; } return view; } This "else" piece waits until the blue marble drops in then recenters the map. The problem i have with that part is that when i go back to the previous View Controller i remove all annotations, so when i come back in the User location (for some reason) does not pop back in. How do i get this to pop back in? thanks in advance guys

    Read the article

  • Issues declaring already existing NSMutableArray in new class

    - by Graeme
    I have a class (DataImporter) which has the code to download an RSS feed. I also have a view and separate class (TableView) which displays the data in a UITableView and starts the parsing process, storing parsed information in an NSMutableArray (items) which is located in the (TableView) subclass. Now I wish to add a UIMapView which displays the items in the (items) NSMutableArray. Herein lies the issue - I need to somehow get the data from the (items) NSMutableArray into the new (mapView) subclass which I'm struggling with - and I preferably don't want to have to create a new class to download the data again for the mapView class when it already is in the applications memory. Is there a way I can transfer the information from the NSMutableArray (items) class to the (mapView) class (i.e. how do I declare the NSMutableArray in the (mapView) class)? Here's a overview of how the system works: App opened Data downloaded (using DataImporter class) when (TableView) viewDidLoad runs Data stored in NSMutableArray accessible by the (TableView) class And from here I need to access and declare the array from a new (mapView) class. Any help greatly appreciated, thanks. Code for viewDidLoad MapKit: Data *data = nil; NSString *ilocation = [data locations]; NSString *ilocation2 = @"New Zealand"; NSString *inewlString; inewlString = [ilocation stringByAppendingString:ilocation2]; NSLog(@"inewlString=%@",inewlString); if(forwardGeocoder == nil) { forwardGeocoder = [[BSForwardGeocoder alloc] initWithDelegate:self]; } // Forward geocode! [forwardGeocoder findLocation: inewlString]; Code for parsing data into original NSMutable Array: - (void)beginParsing { NSLog(@"Parsing has begun"); //self.navigationItem.rightBarButtonItem.enabled = NO; // Allocate the array for song storage, or empty the results of previous parses if (incidents == nil) { NSLog(@"Grabbing array"); self.datas = [NSMutableArray array]; } else { [datas removeAllObjects]; [self.tableView reloadData]; } // Create the parser, set its delegate, and start it. self.parser = [[DataImporter alloc] init]; parser.delegate = self; [parser start]; }

    Read the article

  • MkMapView Zoom Level

    - by meetS
    I m using MkMapView with google maps.I succeed to show map view and address with annotation pin.But I want increased zoom level.How Can I Set it programmatically?? (void) showMyAddress { //Hide the keypad MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta=0.2; span.longitudeDelta=0.2; CLLocationCoordinate2D location = [self addressLocation]; region.span=span; region.center=location; if(addAnnotation != nil) { [mapView removeAnnotation:addAnnotation]; [addAnnotation release]; addAnnotation = nil; } addAnnotation = [[AddAnnotation alloc] initWithCoordinate:location ]; [addAnnotation setMTitle:@"abc"]; [addAnnotation setMSubTitle:@"def."] [mapView addAnnotation:addAnnotation]; [mapView setRegion:region animated:TRUE]; [mapView regionThatFits:region]; } -(CLLocationCoordinate2D) addressLocation { NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", [@"abc" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSStringEncodingConversionAllowLossy error:nil]; NSArray *listItems = [locationString componentsSeparatedByString:@","]; double latitude = 0.0; double longitude = 0.0; if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) { latitude = [[listItems objectAtIndex:2] doubleValue]; longitude = [[listItems objectAtIndex:3] doubleValue]; } else { } CLLocationCoordinate2D location; location.latitude = latitude; location.longitude = longitude; return location; }

    Read the article

  • MKMapKit custom annotations being added to map, but are not visible on the map

    - by culov
    I learned a lot from the screencast at http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/ , and ive been trying to incorporate the way he creates a custom annotation into my iphone app. He is hardcoding annotations and adding them individually to the map, whereas i want to add them from my data source. So i have an array of objects with a lat and a lng (ive checked that the values are within range and ought to be appearing on the map) that i iterate through and do [mapView addAnnotation:truck] once this process is completed, i check the number of annotations on the map with [[mapView annotations] count] and its equal to the number it ought to be, so all the annotations are getting added onto the mapView, but for some reason I cant see any annotations in the simulator. I've compared my code with his in all the pertinent places many times, but nothing seems to stand out as being incorrect. Ive also reviewed my code for the last several hours trying to find a point where I do something wrong, but nothing is coming to mind. The images are named just as they are assigned in the custom AnnotationView, the loadAnnotation function is done properly, etc... i dont know what it could be. so i suppose if i could have the answer to one question it would be, what are possible causes for a mapView to contain several annotations, but to not show any on the map? Thanks

    Read the article

  • MKMapView loading all annotation views at once (including those that are outside the current rect)

    - by jmans
    Has anyone else run into this problem? Here's the code: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(WWMapAnnotation *)annotation { // Only return an Annotation view for the placemarks. Ignore for the current location--the iPhone SDK will place a blue ball there. NSLog(@"Request for annotation view"); if ([annotation isKindOfClass:[WWMapAnnotation class]]){ MKPinAnnotationView *browse_map_annot_view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"BrowseMapAnnot"]; if (!browse_map_annot_view) { browse_map_annot_view = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"BrowseMapAnnot"] autorelease]; NSLog(@"Creating new annotation view"); } else { NSLog(@"Recycling annotation view"); browse_map_annot_view.annotation = annotation; } ... As soon as the view is displayed, I get 2009-08-05 13:12:03.332 xxx[24308:20b] Request for annotation view 2009-08-05 13:12:03.333 xxx[24308:20b] Creating new annotation view 2009-08-05 13:12:03.333 xxx[24308:20b] Request for annotation view 2009-08-05 13:12:03.333 xxx[24308:20b] Creating new annotation view and on and on, for every annotation (~60) I've added. The map (correctly) only displays the two annotations in the current rect. I am setting the region in viewDidLoad: if (center_point.latitude == 0) { center_point.latitude = 35.785098; center_point.longitude = -78.669899; } if (map_span.latitudeDelta == 0) { map_span.latitudeDelta = .001; map_span.longitudeDelta = .001; } map_region.center = center_point; map_region.span = map_span; NSLog(@"Setting initial map center and region"); [browse_map_view setRegion:map_region animated:NO]; The log entry for the region being set is printed to the console before any annotation views are requested. The problem here is that since all of the annotations are being requested at once, [mapView dequeueReusableAnnotationViewWithIdentifier] does nothing, since there are unique MKAnnotationViews for every annotation on the map. This is leading to memory problems for me. One possible issue is that these annotations are clustered in a pretty small space (~1 mile radius). Although the map is zoomed in pretty tight in viewDidLoad (latitude and longitude delta .001), it still loads all of the annotation views at once. Thanks...

    Read the article

  • android bindservice

    - by mnish
    hi, I get null pointer exception at line mService.start() when i try to bind to an already started service. I do the same thing from different activity(where the service gets started) everythig goes right. All these activities are part of one application. What do you think I do wrong? public class RouteOnMap extends MapActivity{ private static final int NEW_LOCATION = 1; private static final int GPS_OFF = 2; private MapView mMapView; private ILocService mService; private boolean mServiceStarted; private boolean mBound; private Intent mServiceIntent; private double mLatitude, mLongitude; private ServiceConnection connection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder iservice) { mService = ILocService.Stub.asInterface(iservice); mBound = true; } public void onServiceDisconnected(ComponentName className) { mService = null; mBound = false; } }; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.mapview); mMapView = (MapView) findViewById(R.id.mapview); mMapView.setBuiltInZoomControls(true); mServiceIntent = new Intent(); mLatitude = 0.0; mLongitude = 0.0; mBound = false; } @Override public void onStart(){ super.onStart(); mServiceIntent.setClass(this, LocationService.class); //startService(mServiceIntent); if(!mBound){ mBound = true; this.bindService(mServiceIntent, connection, Context.BIND_AUTO_CREATE); } } @Override public void onResume(){ super.onResume(); try { mService.start(); } catch (RemoteException e) { e.printStackTrace(); } } @Override public void onPause(){ super.onPause(); if(mBound){ this.unbindService(connection); } } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } }

    Read the article

  • Application get crash while using NSAutoreleasepool inside MKMapview regionDidChangeAnimated method

    - by Ram
    Hi, i am working on a map application, in that i like to drop the pins (as in Zillow apps) when ever user change the map view. I am using following code code. i am try to load the xml data from server using NSAutoreleasepool to do the xml parsing in the background thread. (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{ NSLog(@"inside region did changed "); urlString =[NSString stringWithFormat: @"http://asdfasdasdf.com/asdfasdf/mapxml.php]; [stories1 release]; [mapview removeAnnotations:eventPoints1]; eventPoints1 = [[NSMutableArray array] retain]; [self performSelectorInBackground:@selector(callParsing) withObject:nil]; } -(void)callParsing{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self parseXMLFileAtURL:urlString]; [self performSelectorOnMainThread:@selector(droppingPin) withObject:nil waitUntilDone:YES]; [pool drain]; } The above code is working fine, but once i changed the mapview, the appllication get crashed. Anyone can help me to fix the issue? thanks in advance.

    Read the article

  • MapKit custom annotations being added to map, but are not visible on the map

    - by culov
    I learned a lot from the screencast at http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/ , and ive been trying to incorporate the way he creates a custom annotation into my iphone app. He is hardcoding annotations and adding them individually to the map, whereas i want to add them from my data source. So i have an array of objects with a lat and a lng (ive checked that the values are within range and ought to be appearing on the map) that i iterate through and do [mapView addAnnotation:truck] once this process is completed, i check the number of annotations on the map with [[mapView annotations] count] and its equal to the number it ought to be, so all the annotations are getting added onto the mapView, but for some reason I cant see any annotations in the simulator. I've compared my code with his in all the pertinent places many times, but nothing seems to stand out as being incorrect. Ive also reviewed my code for the last several hours trying to find a point where I do something wrong, but nothing is coming to mind. The images are named just as they are assigned in the custom AnnotationView, the loadAnnotation function is done properly, etc... i dont know what it could be. so i suppose if i could have the answer to one question it would be, what are possible causes for a mapView to contain several annotations, but to not show any on the map? Thanks

    Read the article

  • Attempting to calculate width of Map Overlays on the fly

    - by Bloudermilk
    Hey all- I am working on an Android app that utilizes the Google Maps API MapView, MapController, MapActivity, and ItemizedOverlay. I am basically trying to recreate certain functionalities of the Maps app (damn Google for not providing speech bubbles—for lack of a better name—for items!), particularly those speech bubbles. I have an invisible XML structure for the speech bubble in the XML layout file containing my MapView. The first time I show a speech bubble I grab that XML and remove it from it's current parent, applying some ItemizedOverlay.LayoutParams to it, and add it to the MapView as an Overlay. I position it above the item that was selected, fill it with the proper text, then set it to visible. This all works great. The goal here, though, is to also automatically animate the map to reveal any parts of a speech bubble that may be off-screen when it opens. So I'm trying popup.getWidth() (popup is the instance of my LinearLayout that is the speech bubble) after I do all the manipulation to the bubble, even after I display it to the user. Problem is, popup.getWidth() is returning me the width of the previously displayed popup, not the currently displayed one. I can't figure out why this would be happening if I'm fetching the width after I set it to visible with its new dimensions (which, by the way, are relative when I'm setting them with LayoutParams: fill_content for both width and height).. I have even tried forcing both the MapView and the "popup" to invalidate() before trying to fetch the width. Any ideas why this may be happening? How can I force the View to settle into its new dimensions before trying to fetch them? Thanks! Nick

    Read the article

  • Obtain reference to View in ActionScript class within ViewNavigatorApplication

    - by chb
    I've got a very simple project in FlashBuilder 4.5. It's a mobile application of type ViewNavigatorApplication with a single view, MapView. In the MapView.mxml file, I've got a Flex component of type Map declared in xml. <?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" name="CatBusMapView"> <fx:Script> <![CDATA[ import com.esri.ags.Map; .... ]]> </fx:Script> <fx:Declarations> .... </fx:Declarations> <esri:Map id="cbm"> ... </esri:Map> </s:View> In this same project, I've an actionscript class called UserGeolocation. In this class, I'm attempting to get a reference to this map component. So far, I can get a reference to the top-level application, its ViewNavigator and the NavigationStack of said ViewNavigator. However, I cannot find a way to access the MapView, much less the map I've declared within it. I'm aware of methods like firstView() and activeView(), but I want an absolute solution, one that retrieves the view regardless of whether or not it's first or active. I've tried navigator.getChildByName("MapView") with no luck.

    Read the article

  • MKMapView doesn't want to call didAddAnnotationViews method

    - by TheLearner
    I am writing a little map kit app but it doesn't want to call the delegate method didaddannotationviews: (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views { //Get the first MKAnnotationView from the views returned MKAnnotationView *annotationView = [views objectAtIndex:0]; //Get the annotation from the first annotation view and save it in a variable which can hold any object as long as it implements mkannotation id <MKAnnotation> mp = [annotationView annotation]; //Create a region MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 250, 250); //As the mapview to animate i.e. display the region [mv setRegion:region animated:YES]; } @interface WhereAmIAppDelegate : NSObject { UIWindow *window; CLLocationManager *locationManager; IBOutlet MKMapView *mapView; IBOutlet UIActivityIndicatorView *activityIndicator; IBOutlet UITextField *locationTitleField; }

    Read the article

  • Custom annotationView images revert to pins when clicked

    - by Danny Tuppeny
    I'm displaying custom images on a map (instead of the default pins) using the code below. However, when I tap on an item (and the callout appears), the image reverts to the default red pin. How can I keep my custom image, even when the callout is displayed? - (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *pinAnnotation = nil; if (annotation != mapView.userLocation) { static NSString *pinID = @"mapPin"; pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pinID]; if (pinAnnotation == nil) pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinID] autorelease]; // Set the image pinAnnotation.image = [UIImage imageNamed:@"TestIcon.png"]; // Set ability to show callout pinAnnotation.canShowCallout = YES; // Set up the disclosure button on the right side UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; pinAnnotation.rightCalloutAccessoryView = infoButton; [pinID release]; } return pinAnnotation; [pinAnnotation release]; }

    Read the article

  • mkmapview userlocation annimation issue

    - by Gedeon
    I have issue with userlocation in mkmapview. The thing is that i have navigation controller which pushes mapview , as soon as it pushes it userlocation is queried. But if user pop mapview view before userlocation animation is finished , it throws exception because animation is trying to access deallocated mapview instance. So my question is , how to prevent that. I could do it by disabling back button , but i am not sure if that right way to take. Does anybody know how to stop current animation?

    Read the article

  • UIView animation not working

    - by Daniel
    I have the following code to do a UIView animation: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.0]; [UIView setAnimationDelegate:self]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mapView.view cache:NO]; [self addSubview:detailView]; [mapView removeFromSuperview]; [UIView commitAnimations]; It works when I dont add the detailView. What actually happens is the equivalent of this: [self addSubview:detailView]; [mapView removeFromSuperview]; Please help.

    Read the article

  • Strange Java Coding??? Class in class???

    - by poeschlorn
    Hi guys, I got a question about Java coding in general... In some sample codes there are methods and classes declared WITHIN other methods and/or classes.... I've never heard/red about this...what effect does this kind of programming have? Wouldn't it be better to write down classes in a seperate file and methods side by side and not within each other (like every book tells you)? What are the advantages and disadvantages of this kind of programming? Here's an example of what I mean: Handler mHandler = new Handler() { public void handleMessage(android.os.Message msg) { TextView textView = (TextView) findViewById(R.id.description); textView.setText(mRoad.mName + " " + mRoad.mDescription); MapOverlay mapOverlay = new MapOverlay(mRoad, mapView); List<Overlay> listOfOverlays = mapView.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); mapView.invalidate(); }; };

    Read the article

  • How do I get the users location latitude and longitude?

    - by kevin Mendoza
    I need to access the users location in this method contained in the mainViewController -(void)loadAnnotations{ [mapView removeAnnotations:mapView.annotations]; CLLocationCoordinate2D workingCoordinate; workingCoordinate.latitude= //here i need the users latitude workingCoordinate.longitude= //here i need the users longitude NSLog(@" this is %@", workingCoordinate.latitude); iProspectLiteAnnotation *tempMine = [[iProspectLiteAnnotation alloc] initWithCoordinate:workingCoordinate]; [tempMine setTitle:@"Present Location"]; [tempMine setAnnotationType:iProspectLiteAnnotationTypeUser]; [mapView addAnnotation:tempMine]; } however the mainViewController is already set to <fipsideViewControllerDelegate> What should I add to the header file and the implementation file to poll the location Manager for the users current latitude and longitude?

    Read the article

  • iPhone Application

    - by user553627
    Hello, Im working on an iPhone project using xcode and i actually have not programmed using objective-c before. So, my problem mainly is that my app crashes whenever i hit the button that it suppose to show a view of the world map. I think the problem is within the last 2 lines of the code but still i cant figure out why ?!! because whenever i comment out the line "[self presemtM.....]" the program doesn't crash. Would appreciate your help! -(IBAction) pushedGo:(id)sender { CLLocationCoordinate2D coord = {37.331689, -122.030731}; MapViewController *mapView = [[MapViewController alloc] initWithCoordinates:coord andTitle:@"Apple" andSubTitle:@"111"]; [self presentModalViewController:mapView animated:YES] [mapView release]; }

    Read the article

  • An offscreen MKMapView behaves differently in 3.2, 4.0

    - by Duane Fields
    In 3.1 I've been using an "offscreen" MKMapView to create map images that I can rotate, crop and so forth before presenting them the user. In 3.2 and 4.0 this technique no longer works quite right. Here's some code that illustrates the problem, followed by my theory. // create map view _mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, MAP_FRAME_SIZE, MAP_FRAME_SIZE)]; _mapView.zoomEnabled = NO; _mapView.scrollEnabled = NO; _mapView.delegate = self; _mapView.mapType = MKMapTypeSatellite; // zoom in to something enough to fill the screen MKCoordinateRegion region; CLLocationCoordinate2D center = {30.267222, -97.763889}; region.center = center; MKCoordinateSpan span = {0.1, 0.1 }; region.span = span; _mapView.region = region; // set scrollview content size to full the imageView _scrollView.contentSize = _imageView.frame.size; // force it to load #ifndef __IPHONE_3_2 // in 3.1 we can render to an offscreen context to force a load UIGraphicsBeginImageContext(_mapView.frame.size); [_mapView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIGraphicsEndImageContext(); #else // in 3.2 and above, the renderInContext trick doesn't work... // this at least causes the map to render, but it's clipped to what appears to be // the viewPort size, plus some padding [self.view addSubview:_mapView]; #endif when the map is done loading, I snap picture of it and stuff it in my scrollview - (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView { NSLog(@"[MapBuilder] mapViewDidFinishLoadingMap"); // render the map to a UIImage UIGraphicsBeginImageContext(mapView.bounds.size); // the first sub layer is just the map, the second is the google layer, this sublayer structure might change of course [[[mapView.layer sublayers] objectAtIndex:0] renderInContext:UIGraphicsGetCurrentContext()]; // we are done with the mapView at this point, we need its ram! _mapView.delegate = nil; [_mapView release]; [_mapView removeFromSuperview]; _mapView = nil; UIImage* mapImage = [UIGraphicsGetImageFromCurrentImageContext() retain]; UIGraphicsEndImageContext(); _imageView.image = mapImage; [mapImage release], mapImage = nil; } The first problem is that in 3.1 rendering to a context would trigger the map to begin loading. This no longer works in 3.2, 4.0. The only thing I have found would trigger the load is to temporarily add the map to the view (i.e. make it visible). The problem being that the map only renders to the visible area of the screen, plus a little padding. The frame/bounds are fine, but it appears to be "helpfully" optimizes the loading to limit the tiles to those visible on the screen or close to it. Any ideas how to force the map to load at full size? Anyone else have this issue?

    Read the article

  • iPhone MKMapView force callout bubble

    - by Mark
    Is it possible to force the call out bubble to be open all the time? I tried putting the following code in didAddAnnotionViews: for (id<MKAnnotation> currentAnnotation in mapView.annotations) { [mapView selectAnnotation:currentAnnotation animated:NO]; } Which works, however, when I single tap the MKMapView the bubble disappear. I want to avoid this behavior.

    Read the article

  • current location too slow for view

    - by Christian
    Hi, I make an App with a Map in the App and a button to change to the google.Map-App. The code for my position is: -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { float avgAccuracy = (newLocation.verticalAccuracy + newLocation.horizontalAccuracy)/2.0; if (avgAccuracy < 500) { [locationManager stopUpdatingLocation]; locationManager.delegate = nil; } storedLocation = [newLocation coordinate]; The code for the view is: - (void)viewDidLoad { [super viewDidLoad]; UIImage *image = [UIImage imageNamed: @"LogoNavBar.png"]; UIImageView *imageview = [[UIImageView alloc] initWithImage: image]; UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView: imageview]; self.navigationItem.rightBarButtonItem = button; [imageview release]; [button release]; locationManager=[[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = kCLDistanceFilterNone; [locationManager startUpdatingLocation]; mapView.showsUserLocation = YES; NSLog(@"storedLocation-latitude für MKregion: %f", storedLocation.latitude); MKCoordinateRegion region; region.center.latitude = (storedLocation.latitude + 45.58058)/2.0; region.center.longitude = (storedLocation.longitude - 0.546835)/2.0; region.span.latitudeDelta = ABS(storedLocation.latitude - 45.58058); region.span.longitudeDelta = ABS(storedLocation.longitude + 0.546835); [mapView setRegion:region animated:TRUE]; MKCoordinateRegion hotel; hotel.center.latitude = 45.58058; hotel.center.longitude = -0.546835; HotelPositionMarker* marker = [[HotelPositionMarker alloc] initWithCoordinate:hotel.center]; [mapView addAnnotation:marker]; [marker release]; } My problem: when the "viewDidLoad" start, the "storedLocation" is still 0.0000 it takes a bit longer to get the own position than to start the view. The Log for the "storedLocation" in the "viewDidLoad"-section is 0 while the Log of the "storedLocation" in the "-(IBAction)" when the map is visible contains the right values. How can I manage it to have my coordinates before the view load? I need them to center the view concerning the own position and the position given by me. MKCoordinateRegion region; region.center.latitude = (storedLocation.latitude + 45.58058)/2.0; region.center.longitude = (storedLocation.longitude - 0.546835)/2.0; region.span.latitudeDelta = ABS(storedLocation.latitude - 45.58058); region.span.longitudeDelta = ABS(storedLocation.longitude + 0.546835); [mapView setRegion:region animated:TRUE];

    Read the article

  • use pin.title in other class

    - by Marco
    Hello i have implemented the following code: - (void) mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annView calloutAccessoryControlTapped:(UIControl *)control { name = annView.annotation.title; NSLog(name, [annView description]); } and how can I use the variable name in another class? can you please help me, i am new in iphone developing!

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11  | Next Page >