TDBF Posted July 10, 2017 Posted July 10, 2017 I am trying to get Google Maps to display in Pages. I have set up a custom field using the Address 'Type' in the 'General Options' tab, and enabled 'Show Map' within the 'Display Options' tab. Display View Format is set to No Formatting. I have created the google API key required for Google Maps and the settings for this has been done correctly (No errors anyway). The code in the Record template used is: {$record->customFieldDisplayByKey('venue-address', 'display')|raw} The 'venue-address' is the variable I used as the Template Key. However, only the address is shown, but not the Google Map is displayed. An example of this can be seen here. Is this the correct way of getting Google Maps to display?
opentype Posted July 10, 2017 Posted July 10, 2017 Do you need to access that in the record template specifically? The preferred way to do this is to just output the field as top or bottom field. And if you want to style the field output, you do that in the field setting itself where you can access {map} and {address} separately.
TDBF Posted July 10, 2017 Author Posted July 10, 2017 4 minutes ago, opentype said: Do you need to access that in the record template specifically? Yes, I need control over the placement of the maps and believe that using the above code should give me what I need. 5 minutes ago, opentype said: The preferred way to do this is to just output the field as top or bottom field. And if you want to style the field output, you do that in the field setting itself where you can access {map} and {address} separately. I do not use these methods of displaying the fields as most of my templates are highly customised. I'm sorry, but doing a loop of fields in this way is no good to me and means the information will not be presented in a way of my choosing. I changed the template to the default and changed the Display View Format in Display Options to Label Value, and the map displays. So now I know that the Google maps does indeed work. But this is not workable for me. Is there another way of displaying Google Maps without resorting to the basic format?
opentype Posted July 10, 2017 Posted July 10, 2017 16 minutes ago, TDBF said: means the information will not be presented in a way of my choosing. What do you want to do differently regarding the map that you can’t do when its called in a loop?
TDBF Posted July 10, 2017 Author Posted July 10, 2017 1 hour ago, opentype said: What do you want to do differently regarding the map that you can’t do when its called in a loop? What I am trying to doing is a lot more non-linear and a little outside the scope of the method in which you are referring too. I eventually did something along the lines of: {{$mapInfos = json_decode($record->field_40, TRUE);}} {expression="\IPS\GeoLocation::buildFromJson( json_encode((object) array('lat' => $mapInfos['lat'], 'long' => $mapInfos['long'])) )->map()->render( 300, 300, 2 )" raw="TRUE"} While it isn't perfect, it gets the job done and I am not wasting my time searching for an answer which I cannot seem to find on this site (due to little or no documentation on the subject matter). If there is another way of doing this, which would be considered the 'correct' of doing it without having to resort to for-loops and the view formats? If so, then I would be most appreciative. Thanks.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.