I have a console command plugin that needs to periodically go and fetch property data via API and import it into Craft. I can pull in basic property information but when it comes to importing the data into Smart Map field I'm a bit lost as how to format the data so that it saves correctly. Has anyone had to do this before?
I don't think the console command part should make much difference. Basically I am trying to save a smartmapfield on my entry. From the API I am using I get a string with the full address. I first extract the postcode and then use the smartmap plugin to get the Lat and Lng values:
$postcode = $matches; //Look up Latitude and Longitude from Google API $response = craft()->smartMap->lookupCoords($postcode); $lat = $response['lat']; $lng = $response['lng'];
What I am not sure of is how to format this data so that it can be saved to the entry. So for standard fields thats straight forward:
$entry->getContent()->title = $property['RoomName'];
How do I do this for my smartmap field?