Adding Maps to an application

A place for users and developers of the Xataface to discuss and receive support.

Adding Maps to an application

Postby wisni1rr » Thu Feb 23, 2012 12:52 pm

I just watched a video on youtube that had a simple example for having an embedded map.

http://youtu.be/HTm-3Cduafw

I was wondering if anyone could guide me as to how I could have the map display in the Xataface framework. I only need it to show up on 1 table's detail page. I'm not sure on the best placing of the map on the details page of a record. However, the map should be placed logically. (Note: the details page in question already has a PIC as a logo.

I'm playing around with it. I figured I would ask in case someone can solve this issue for me in second.

Thanks!
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Adding Maps to an application

Postby shannah » Thu Feb 23, 2012 2:10 pm

You can add custom sections to the view tab using section__sectionname()
http://xataface.com/wiki/How_to_Add_Cus ... o_View_Tab

That is probably the easiest place to add content to the view tab.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Adding Maps to an application

Postby wisni1rr » Thu Feb 23, 2012 3:05 pm

Thanks again, Steve!

I was wondering now how I could call the fields for the current record as variables. All the fields required to generate an address are in the same table that the delegate class resides.

I need theses fields (spelled as variables):
Code: Select all
$StreetNO, $StreetName, $City, $State, $Zip
and save them as a new variable
Code: Select all
$locationString = "$StreetNo,+$StreetName,+$City,+$State,+$Zip


So my delegate would be something like this:
Code: Select all
function section__Map(&$record){
    return array(
        'content' => <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=<?php echo$locationString?>&amp;ie=UTF8&amp;hq=&amp;hnear=<?php echo $locationString;?>&amp;t=m&amp;z=14&amp;output=embed"></iframe>
        'class' => 'main',
        'label' => 'Property Map via Google'
    );
}
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Adding Maps to an application

Postby shannah » Thu Feb 23, 2012 3:27 pm

Code: Select all
$locationString = $record->val('StreetNo').','.$record->val('StreetName').','. ... etc....
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Adding Maps to an application

Postby wisni1rr » Thu Feb 23, 2012 3:36 pm

Can I use php on the 'content' array?

For example:

Code: Select all
  function section__map(&$record){
          return array(
           'content' => '$record->val("City")',
           'class' => 'main',
           'label' => 'Property Map via Google'
    );
}


My content will start off with traditional <html> tags but goes in and out of php a few times.
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Adding Maps to an application

Postby ADobkin » Thu Feb 23, 2012 3:54 pm

Yes, you can do that, but variables are not parsed inside of single quotes. Either change them to double quotes or remove them altogether, depending on what else you plan on adding to it.
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: Adding Maps to an application

Postby wisni1rr » Thu Feb 23, 2012 4:07 pm

Thank you for pointing that out. I had forgotten that rule...
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Adding Maps to an application

Postby wisni1rr » Thu Feb 23, 2012 4:24 pm

The content I am using also contains some double quotes...

I tried switching the content to use single quotes instead. The application works. However, it behaves unexpectedly. When using double quotes, the details section becomes hidden. If you collapse the map section I have created, it will flicker between expanded and collapsed.

The following code works how I would like it to. The problem is it is not dynamic.

Code: Select all
function section__map(&$record){
          return array(
           'content' => '<iframe width="700" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=528+15TH+ST,+Port+Huron,+MI&amp;aq=&amp;sll=42.827639,-82.633667&amp;sspn=0.80171,1.234589&amp;ie=UTF8&amp;hq=&amp;hnear=528+15th+St,+Port+Huron,+Michigan+48060&amp;ll=42.978434,-82.441678&amp;spn=0.006248,0.009645&amp;t=m&amp;z=16&amp;output=embed"></iframe>',
           'class' => 'main',
           'label' => 'Property Map via Google'
    );
}


Removing the quotes all together will generate a Parse error: unexpected '<'.
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Adding Maps to an application

Postby wisni1rr » Fri Feb 24, 2012 12:11 pm

I figured it out. Here is my solution for anyone who was wondering:

Code: Select all
function section__map(&$record){
                $locationString = $record->val('StreetNo').' '.$record->val('StreetName').' '.$record->val('City').' '.$record->val('State');
                $locationString = urlencode($locationString);
          return array(
           'content' => "<iframe width='725' height='350' frameborder='1' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=$locationString&amp;ie=UTF8&amp;hq=&amp;hnear=$locationString&amp;t=m&amp;z=16&amp;iwloc=A&amp;output=embed'></iframe>",
           'class' => 'main',
           'label' => 'Property Map via Google'
    );
}
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 5 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved