Quite a few of the things I expected to be very difficult with CakePHP have actually been "a breeze." Well, not a breeze, but doable. Anyway, no fanfare. Here's how to integrate mapping with your application.
Add the data fields I'd recommend fields called "latitude" and "longitude," of the type FLOAT. You can use strings if you want, but that will eliminate some cool possibilities in the future. And have a field called "location" or something of that sort. Add the input Let's say that the *model* is called "Place" you could use this. <?php echo $html->hidden('Place/latitude', array('id' => 'PlaceLatitude')); ?> <?php echo $html->hidden('Place/longitude', array('id' => 'PlaceLongitude')); ?> <?php echo $html->input('Place/name', array('class' => 'primary_input')); ?> <label for="PlaceZip">location</label> <?php echo $html->input('Place/location'); ?> <a class="secondmap" onclick="secondmap('PlaceLocation', 'PlaceLatitude', 'PlaceLongitude');" href="#">map</a> Add the Action Replace "YOUR_APP" with your AppId & put this in a controller (for instance, Places) <?php function geocode($location) { // Allowed hostname (api.local and api.travel are also possible here) define ('HOSTNAME', 'http://api.local.yahoo.com/MapsService/V1/geocode?'); // Get the REST call path from the AJAX application // Is it a POST or a GET? //$path = ($_POST['yws_path']) ? $_POST['yws_path'] : $_GET['yws_path']; $url = HOSTNAME.'appid='.'YOUR_APP'.'&location='.urlencode($location); // Open the Curl session $session = curl_init($url); // If it's a POST, put the POST data in the body if (isset($_POST['yws_path'])) { $postvars = ''; while ($element = current($_POST)) { $postvars .= key($_POST).'='.$element.'&'; next($_POST); } curl_setopt ($session, CURLOPT_POST, true); curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars); } // Don't return HTTP headers. Do return the contents of the call curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Make the call $xml = curl_exec($session); // The web service returns XML. Set the Content-Type appropriately header("Content-Type: text/xml"); echo $xml; curl_close($session); exit(); } ?> h4. Add SecondMap & ThirdMap Download the files http://notes.we-run.com/file_download/1 thirdmap.js http://notes.we-run.com/file_download/2 secondmap.js and drop them in webroot/js and include them in layouts/default.thtml http://www.google.com/apis/maps/signup.html Get a Google Maps API Key Output stuff. In the "index" or "list" view, when you're outputting the list of geotagged-things, use code like this: <div id="map" style="height: 250px;"> <?php foreach ($your_places as $place): ?> <?php if($place['Place']['latitude'] && $place['Place']['longitude']): ?> <ul> <li class="info"><?php echo $html->link($place['Place']['name'], '/places/view/'.$place['Place']['id']); ?></li> <li class="latitude"><?php echo $place['Place']['latitude']; ?></li> <li class="longitude"><?php echo $place['Place']['longitude']; ?></li> </ul> <?php endif; ?> <?php endforeach; ?> </div> <script type="text/javascript"> thirdMap('map'); </script> of course, replace $place['Place'] with whatever your action is. Hooray! You should be all set. This will leave you with a quick, cross-browser (screenreader compatible!) Google Maps solution. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~----------~----~----~----~------~----~------~--~---