Page 1 of 1

To Google Maps or Not?

Posted: Sun Nov 22, 2009 9:25 pm
by volomike
I'm working on a real estate site proposal. I'm considering Google Maps, but the problem I have is that some parts of the site will only be shown to logged in members. And that poses a problem because Google Maps API specifically states that it is free for use only when the page it is placed upon is able to be seen by EVERYONE, not just a single member.

So what's a workaround? Do you employ some kind of spider-check to let Google on through? Do you use an alternative maps API?

Re: To Google Maps or Not?

Posted: Sun Nov 22, 2009 9:53 pm
by John Cartwright
http://code.google.com/apis/maps/faq.html#tos_commercial wrote:If you charge people to place information on your map (e.g. to list their homes for sale), but you display this information using the Google Maps API on a free part of your site, you'll also meet the Google Maps API Terms of Service.
and more info here

Basically, if all of your content is behind closed doors, then that's a no go.

I'm not aware of any worthy alternatives to Google Map. Might be worth looking Microsoft's new Bing Maps and their terms to see what their deal is.

Re: To Google Maps or Not?

Posted: Sun Nov 22, 2009 10:34 pm
by volomike
Ack. Microsoft.

Re: To Google Maps or Not?

Posted: Sun Nov 22, 2009 10:54 pm
by volomike
I found something neat called OpenLayers, but you have to supply it with your own map data.

http://www.openlayers.org/

However, I think what I'm going to do with Google Maps API is make the "View Map" button on the page refresh the entire page with "&map=1" on the end, and when one comes in like this, it will drop any kind of membership check temporarily but just for that page. That way, the Google bot that checks for TOS violations will get right on through and everyone is happy. It's not really a hack or a TOS violation -- anyone who mails that URL to someone else will also be able to get right in on that page. It's just that when they go clicking on other pages after that, they'll get redirected to a login page. But for the map page -- they'll get right on in just like Google would.

Re: To Google Maps or Not?

Posted: Tue Nov 24, 2009 2:08 pm
by greyhoundcode
I've made use of the Yahoo! Maps API in a WP plugin, and found it to be just the ticket. I am not aware of a similar restraint within the Yahoo! Maps T&Cs, although there is a different restriction you will need to work around:
Terms and conditions (1.F.iii)

You must not use the Yahoo! Maps APIs to operate nuclear facilities, life support, or other mission critical application where human life or property may be at stake

Re: To Google Maps or Not?

Posted: Tue Nov 24, 2009 7:33 pm
by josh
I use a front controller plugin for my framework, a simple class that gets instantiated and added to the front controller plugin stack.

The end result is that I just created controllers & actions, and set up permissions in an ACL object (http://framework.zend.com/manual/en/zend.acl.html).

There is never any code in my actions like if( $role != 'admin' ), the only time permissions logic will be in a controller is something like
$this->assert( $user->owns( $someRecord )

Before dispatch, this auth plugin looks at the request object being used to dispatch, and looks at the current user. It makes a decision and modifies the request object such that an error controller will be dispatched instead of the requested controller, if necessary. http://framework.zend.com/manual/en/zen ... ugins.html

I found some example code on the net and modified it, here is what I use

Code: Select all

<?php
/**
* ACL controller plugin
* @category Ne8
* @package Ne8_Controller
* @subpackage Plugin
*/
class Ne8_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
{
    /**
     * @var Zend_Acl
     **/
    protected $_acl;
 
    /**
     * @var string
     **/
    protected $_roleName;
 
    /**
     * @var array
     **/
    protected $_errorPage;
 
    /**
     * Constructor
     *
     * @param mixed $aclData
     * @param $roleName
     * @return void
     **/
    public function __construct(Zend_Acl $aclData, $roleName = 'guest')
    {
        $this->_errorPage = array('module' => 'default', 
                                  'controller' => 'error', 
                                  'action' => 'denied');
 
        $this->_roleName = $roleName;
 
        if (null !== $aclData) {
            $this->setAcl($aclData);
        }
    }
 
    /**
     * Sets the ACL object
     *
     * @param mixed $aclData
     * @return void
     **/
    public function setAcl(Zend_Acl $aclData)
    {
        $this->_acl = $aclData;
    }
 
    /**
     * Returns the ACL object
     *
     * @return Zend_Acl
     **/
    public function getAcl()
    {
        return $this->_acl;
    }
 
    /**
     * Sets the ACL role to use
     *
     * @param string $roleName
     * @return void
     **/
    public function setRoleName($roleName)
    {
        $this->_roleName = $roleName;
    }
 
    /**
     * Returns the ACL role used
     *
     * @return string
     * @author 
     **/
    public function getRoleName()
    {
        return $this->_roleName;
    }
 
    /**
     * Sets the error page
     *
     * @param string $action
     * @param string $controller
     * @param string $module
     * @return void
     **/
    public function setErrorPage($action, $controller = 'error', $module = null)
    {
        $this->_errorPage = array('module' => $module, 
                                  'controller' => $controller,
                                  'action' => $action);
    }
 
    /**
     * Returns the error page
     *
     * @return array
     **/
    public function getErrorPage()
    {
        return $this->_errorPage;
    }
 
    /**
     * Predispatch
     * Checks if the current user identified by roleName has rights to the requested url (module/controller/action)
     * If not, it will call denyAccess to be redirected to errorPage
     *
     * @return void
     **/
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $resourceName = '';
        $front  = Zend_Controller_Front::getInstance();
        if ( $request->getModuleName() != $front->getDefaultModule() )
        {
            $resourceName .= $request->getModuleName() . ':';
        }
        $resourceName .= $request->getControllerName();        
        try
        {
            /** Check if the controller/action can be accessed by the current user */
            if ( !$this->getAcl()->isAllowed($this->_roleName, strtolower($resourceName), strtolower($request->getActionName()) ) )
            {
                /** Redirect to access denied page */
                $this->denyAccess();
            }
        }
        catch( Exception $e )
        {
            return false;
        }
    }
 
    /**
     * Deny Access Function
     * Redirects to errorPage, this can be called from an action using the action helper
     *
     * @return void
     **/
    public function denyAccess()
    {
        $this->_request->setModuleName($this->_errorPage['module']);
        $this->_request->setControllerName($this->_errorPage['controller']);
        $this->_request->setActionName($this->_errorPage['action']);
    }
}
 
As you can see preDispatch gets called w/ the request object on every dispatch (as per the 'contract' with the Zend Front Controller.), I look for if the user is allowed or not, and the denAccess() method will mutate the request object to cause an error page to dispatch, if applicable. When I initialize this plugin during bootstrapping, I use setRoleName() so the plugin knows what kind of user it is. It calls on it's little friend the ACL object to manage complex permissions.

Re: To Google Maps or Not?

Posted: Tue Nov 24, 2009 9:21 pm
by volomike
josh wrote:I use a front controller plugin for my framework
Um, Josh -- I think you meant to post this response to another thread. This is the Google Maps integration thread.

Re: To Google Maps or Not?

Posted: Wed Nov 25, 2009 12:36 am
by josh
Yeah dude, wtf :crazy: can't find the proper thread, must be going crazy.

On the original topic it seems like if registration is free then it is no problem. An alternative is get some ESRI data and render out maps with the the gd library. You won't get much detail but you will see most roads at least. I have the code and the data for doing something like that

Re: To Google Maps or Not?

Posted: Thu Nov 26, 2009 5:58 am
by greyhoundcode
OpenLayers looks very interesting, and I see that it can also work with Google and Yahoo mapping amongst other formats.

Re: To Google Maps or Not?

Posted: Fri Dec 04, 2009 5:52 am
by timWebUK
I thought this seemed relevant/interesting...

http://news.bbc.co.uk/1/hi/technology/8394252.stm