Forum

Thread tagged as: Question, Problem, Field-Types

Perch Map template

Does the standard Perch 'map' template store any latlng or geocoded coordinates at all? I'm looking at adding a geocode fieldtype to do this, but want to check before I take the plunge! Thanks.

Mat Ranson

Mat Ranson 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, it stores the lat and lng.

OK. I can't seem to retrieve it from skip-template.

$all_venues = perch_content_custom('Venues', array(
'skip-template'=>true
));

print_r($all_venues[0]['locationMap']);

Just gives me the address I entered in the form for that particular location.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, I think you're right.

So how can I retrieve the lat and lng?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't think you'll be able to from the fieldtype as it stands. Instead of creating a new fieldtype, you could just copy the map one and modify it to your needs, however.

OK. I haven't modified a fieldtype before. Where should I start?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I thought your original plan was to create a new field type.

It was, but your previous reply suggested modifying the existing Perch map rather than creating a new field type. I assumed that meant going into perch/core somewhere?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You can create your own Field Types from scratch but it might be simpler to take one of ours as a starting point. That's up to you of course but whichever it isn't going to involve modifying Perch Core. You would take the Field Type, rename it, put it into the addons/fieldtypes folder as normal and then make your changes.

https://docs.grabaperch.com/api/field-types/

OK great. Thanks Rachel.