Skip to main content
edited title
Link

How to programticallyprogrammatically set a Smart Map address field from withinin plugin

added 728 characters in body
Source Link

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?

Edit:

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[0]; 

//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?

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 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?

Edit:

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[0]; 

//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?

added 1 character in body; edited title
Source Link
Brad Bell
  • 67.6k
  • 6
  • 75
  • 145

How to programtically set smartmapa Smart Map address field from within plugin

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 smartmapSmart 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?

How to programtically set smartmap address field from within plugin

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 smartmap field I'm a bit lost as how to format the data so that it saves correctly. Has anyone had to do this before?

How to programtically set a Smart Map address field from within plugin

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?

Source Link
Loading