map kit problem

Discussion in 'iOS Programming' started by jagatnibas, Nov 22, 2011.

  1. jagatnibas macrumors regular

    Joined:
    Jul 28, 2008
    #1
    i worked last in mapkit 2 year back, hence a little rusty.

    i have checked show current location in my mapview, it shows the current location pin at a usa location, i guess cupurtino, but it is not centered. but the MKCoordinateRegion center lat long and mapview center lat long are same.

    i also noticed another thing, that i cannot go further left when i drag left beyond north america, means the map seems to be flat, i thought it would be round and i can drag rounded as many times as i want, please suggest.

    also i am asked to make my current location centered in the map and zoom level to 5 miles, how would i do that ?

    thanks in advance
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    This is all explained really well on some tutorials online though..
    What you need is an zoom on your map..
    Code:
        [self.mapView setRegion: MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake(self.eventAnnotation.coordinate.latitude,self.eventAnnotation.coordinate.longitude), 200, 200) animated:YES];
    this is showing yourself pin his lati/longi, and zooms with it animated to the box of 200,200, whatever fits your needs :)
     
  3. jagatnibas thread starter macrumors regular

    Joined:
    Jul 28, 2008
    #3
    thanks a lot for the help, but why is not the current location centered ?
     
  4. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    You need to zoom based upon your annotation.. I only showed you code how to do that :) you need to show the code your annotation..
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    I think some code and a screenshot from the OP might help us understand the problem better.
     
  6. jagatnibas thread starter macrumors regular

    Joined:
    Jul 28, 2008
    #6
    please see the attached screen shot, the current location is in the left side where as i want it centered and total iphone screen set to 5 miles, rest user should drag and see. i have not added any code for setregion and setcenter as yet, only i have checked show current location in nib file.
     

    Attached Files:

  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    For those of you not wanting to download a file and unzip it to look at a simple screenshot:
     

    Attached Files:

    • map.png
      map.png
      File size:
      58.1 KB
      Views:
      69
  8. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #8
    Oh my, not even custom pins :( hurts ma eyes!

    And you are showing your own location via the normal Mapkit usage of your location. I have no experience on that, what I do, is look for my location via CLLocationManager, and put a pin on my map with my location. and center that..
    Hopefully someone else will set you on their way.
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    So, what are you asking? Are you wondering why the mapView doesn't automatically get centered on the user's location (it doesn't)? Or are you asking for the code to do that centering?
     

Share This Page