Get lat and lon values of CCK Location field

towlie - October 9, 2009 - 11:40
Project:Location
Version:6.x-3.x-dev
Component:Location_views
Category:support request
Priority:normal
Assigned:Unassigned
Status:fixed
Description

Hi,

I want to use the CCK Location Field in order to set map.setCenter of Google Maps I'm displaying via Contemplates in nodes. All I can find in Contemplates is

<?php
print $node->field_location[0]['view']
?>
(I named the CCK field 'location'), which displays the whole location, such as

Germany
51° 24' 46.4832" N, 10° 10' 24.024" E
See map: Google Maps

Is it possible to get the values of latitude and longitude separately, like 51.412912 and 10.17334?

#1

yoda-fr - November 6, 2009 - 16:04

Hi,
I found the answer :

$lat = $field_location[0]['latitude'];
$long = $field_location[0]['longitude'];

"location" is the name of my field.

Hope it will help!

#2

0bar - November 16, 2009 - 20:28

It helped,

I now use 'computed field' to fill the lat and lon values to a different cck field.

Thanks.

#3

nickl - November 26, 2009 - 04:55
Status:active» fixed

Moving this to the documentation project documentation/faq/help so that we don't loose any vital information collected here.

 
 

Drupal is a registered trademark of Dries Buytaert.