Closed (fixed)
Project:
Location
Version:
5.x-3.0
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Dec 2008 at 19:35 UTC
Updated:
29 Jul 2011 at 21:22 UTC
I am writing a module to import some data from an external source. I want to import latitude and longitude data directly into the location module. How do I achieve this for the node object?
For other fields I use $node->body = '.....';
Any hints much appreciated.
Comments
Comment #1
yesct commentedI think you might have to set the number of locations on a node to 1 (or more)
then try something like node->location[0]['latitude']= ...
then something like node_save(...)
?
Post back any thoughts on that, or partial code you try. That will help more people give you more feedback.
also tagging.
ps. I found it helpful to use the devel and/or the contemplate module to find out how to access the parts of location.
Comment #2
ankur commented$node->locations is an array of locations where each array can have values for a 'latitude' key and a 'longitude' key. Building your stdClass node object with this locations attribute and then calling location_save() with this object (as suggested by YesCT above) should do it.