2

I am doing one golf gps app for iPhone. For that I need to show the golf course map on the iPhone device. I searched about that in the internet. There are lot of methods and service providers for doing that golf course mapping(aerial image).

For your reference :

http://sites.google.com/site/mapmakerpedia/maps-101/how-to-map-a-golf-course

Somebody says that we can use google imagery for that. But my question is

 1.  How we could bring that golf course map data into iPhone app?
 2.  Is there any API or method available for that?
 3.  In which format, that golf course map data file will be?
LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114

1 Answers1

1

First, you need to collect latitude and longitude points for your golf courses. How to do that is up to you, and not really an iPhone issue. Depending on how many points you have, to define the fairways and greens (and maybe hazards?), you might want to store all the points in an XML file, that would be bundled as a resource in your application. Or, maybe you store it on a webserver, if the content needs to be updated regularly. Or both. But, the file could be something like this:

<golf-courses>
  <golf-course>
     <name>Pebble Peach</name>
     <par>72</par>
     <fee>$200</fee>
     <holes>
        <hole>
           <number>1</number>
           <par>4</par>
           <fairway>
              <points>
                 <point><lat>-122.1231231</lat><lon>36.0131231</lon></point>
                 <point><lat>-122.1231232</lat><lon>36.0131235</lon></point>
                 <point><lat>-122.1231237</lat><lon>36.0131235</lon></point>
                   ...
              </points>
           </fairway>
           <green> 
              ...
           </green>
        </hole>
     </holes>
  </golf-course>
...
</golf-courses>

Or, you could choose to use a format like KML, which is well designed for map overlays. That would be especially useful if you were able to get existing golf course data already stored in KML. But, from your question, it sounded like you'd be trying to deduce the data yourself from a set of aerial maps.

Then, you need to read the XML data (or KML, or plist data, or Core Data, or however you store it) into your app at startup.

Then, you would probably have a UIViewController that iterated through the data, and plotted the course as polygons. For this, your view controller would use the MapKit framework, and you would probably draw the course as a bunch of green shaded polygons, using MKPolygon. You can see this other answer I posted on the very simplest MKPolygon example.

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207
  • Yes I got your ideas. Many Thanks. You are saying that we should map that location coordinates in mapview. But I have seen some apps in which they are showing only the golf course map and not full google map. How we can do that? If we do that, how can we find the distance between two locations on that course map without using google map? Because in google maps we can get the location coordinate while touching on it. Then how can we implement that? Thanks in advance. – Janar thanan May 15 '12 at 08:06
  • I guess it depends on what you want to do. Even if your app is never meant to show any area outside the boundary of the golf course, you might still want to use MapKit, because it gives you a lot of useful capabilities (like MKOverlays). If you don't use MapKit at all, you'll have to reproduce all that yourself. You can still plot course features as overlays on an MKMapView, and restrict the view from panning away from the course. You could define one MKOverlay for the whole course, and then [use this solution](http://stackoverflow.com/questions/4119117/restrict-mkmapview-scrolling). – Nate May 15 '12 at 20:43
  • If, however, you want to show very detailed elevation contours of the course, which would create thousands of polygons, you probably can't use MapKit (performance). Then, you should look at OpenGL ES which will be a lot more work. But, your question didn't say you needed that, so I'm assuming that you could solve this with only a few overlays per hole. Please append more description to your question if my assumption is incorrect. Thanks. – Nate May 15 '12 at 20:45
  • And [look at this answer](http://stackoverflow.com/questions/3080198/get-the-coordinates-of-a-point-from-mkmapview-on-iphone) for information about getting the location of a user's touch on the MapKit map. This could allow you to provide range-finding to the green. – Nate May 15 '12 at 20:48
  • Thanks. Yes I want to know that how we can do that mapping thing whithout MapKit and MapView. How we can do that using OpenGL ES? I think we can draw the map components using polygons. Am I correct? Then how we can find the distance between two locations in this method while touching the screen? For that do we need location coordinates? Thanks in advance. – Janar thanan May 16 '12 at 05:47
  • @Janar, I haven't done something like that with OpenGL ES, so I can't help you much ... if you don't want to use MapKit, I would edit your question above to mention that, so that other people might get you a solution that works for you. – Nate May 16 '12 at 06:16