Google Maps (LatLng) Element revived from v1 to work with v3

100 views
Skip to first unread message

TheSin

unread,
Oct 18, 2012, 12:16:50 AM10/18/12
to php-form-bu...@googlegroups.com
I got ambitious today and using the old PFBCv1 I built or ported LatLng Element for PFBC3 (only tested with php5.3 variant)

and here it is

Put file in PFBC/Element/LatLng.php

it uses the normal prototype (label, name, attributes)

Attributes has a few map specific additions
        latlngDefaultLocation - array(lat, lng) (default 41.847, -87.661)
        width - width of map in pixels (default 400) (this is also used as a style option for input fields)
        height - height of map in pixels (default 250)
        hideJump - hide the address search bar (default false) 
        mapType - type of map to use (default ROADMAP) (Avail options are ROADMAP, SATELLITE, HYBRID, TERRAIN)
updatelat - input that is updated via js for the latitude only value (default none)
updatelng - input that is updated via js for the longitude only value (default none)

value comes from latlngDefaultLocation

here is an example usage,
        $form = new PFBC\Form("latlng");
        $form->configure(array(
                "prevent" => array(
                        "bootstrap",
                        "jQuery",
                ),
        ));

        $form->addElement(new PFBC\Element\LatLng('My Location:', 'mylatlng', array(
                'latlngDefaultLocation' => array($row['latitude'], $row['longitude']),
                'mapType' => 'HYBRID',
                'zoom' => $zoom,
                'updateLat' => 'latitude',
                'updateLng' => 'longitude',
        )));
        $form->addElement(new PFBC\Element\Textbox("Latitude:", "latitude", array("value" => $row['latitude'], 'id' => 'latitude')));
        $form->addElement(new PFBC\Element\Textbox("Longitude:", "longitude", array("value" => $row['longitude'], 'id' => 'longitude')));


Anyhow hope you like it, I know it's working great for me and I'd love to be able to give back to this project a little.  I'm not 100% familiar with your api at all I kinda just jumped in and got it working in a few hours so I'm not claiming I did things the best way, I just took the old code and tried to convert it the best I could, and I added the updateLat/Lng since I needed to get each value separately and this made my like easier, so I wouldn't have to post process it at all.  It works with hidden fields too which makes it nice and clean IMHO.

Enjoy and thanks for this class once again.
LatLng.php

TheSin

unread,
Oct 18, 2012, 4:44:17 PM10/18/12
to php-form-bu...@googlegroups.com
Forgot to post a pick of what it looks like, this is using the above example code.



TheSin

unread,
Nov 23, 2012, 3:11:38 PM11/23/12
to php-form-bu...@googlegroups.com
Looks like this will break with 3.1, I have an updated version for current svn is there anything I can do to help get this in before release so I don't have to keep updating it?

TheSin

unread,
Dec 5, 2012, 4:27:21 PM12/5/12
to php-form-bu...@googlegroups.com
while I was updating this to work with 3.1 (current svn) I added a new option.

moveToClick - boolean (Default true)

This is nice, for long drags you don't have to go back for the marker it'll go to where you click.

I'm still waiting to hear what I can do to get this added to the next release so I'll post an official update once I hear.
Reply all
Reply to author
Forward
0 new messages