Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Can GoogleMapAPI do this?

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Wed Oct 31, 2007 10:01 pm    Post subject: Can GoogleMapAPI do this? Reply with quote

I can have a little map with a little marker centered on a given lat/lon. No problem.

What I would like now is for the marker to be draggable. I'd like the users to use this to correct their location. After that I can cookie it. The initial guess where the marker is is IP geocoded. But it sometimes way wrong, especially in the case of VPN's. The user says, no I'm not there, I'm actually HERE half mile west of there or 621. miles South Southeast of there, whatever it is he fixes it visually, rather than by looking up lat/lon (which users rarely do anyway and of the three that do two usually screw it up.)
So they may zoom drag and pan pan around in the map a bit
So after the dust settles, I'd like
some magical ajax to snatch it up the marker's location and figure out what the corrected lat/lon is and notify the server.

Any ideas?
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Thu Nov 01, 2007 1:51 am    Post subject: My first swipe at it. Reply with quote

I found this site in Finland that is doing it

http://koti.mbnet.fi/ojalesa/exam/draggable.html

Notice how you can drag the little red icon anywhere you want. The GoogleMapAPI
doesn't have anything that I can see about draggable, so I thought I'd just splice some of my own javascript on to what the googlemapAPI produces and tweak up the map with a draggable marker. I basically borrowed the bit of the finnish guy's code. Here is the wierd thing it says map has no properties. and my spliced on code appears after all Monty's code to create the map and such like. PLUS, if I leave my code out it produces no errors but neither does it output a map.

Here is the test URL http://demo.wazzuplocal.com/distance.php

It's supposed to be a map centered on the WIllamette Valley and have a draggable marker and it's supposed to put the lat/lon in one of the text fields.

I'd like first to know what's wrong clientside and then I'll see what I do serverside.
THanks
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Thu Nov 01, 2007 5:28 pm    Post subject: Still not getting the marker Reply with quote

I solved why the map wasn't outputting.
I put the marker after the document writes for the map but it still says map
has no properties and won't give me the draggable marker.

Should I do the draggable code as document writes? Seems silly but I guess I can.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Thu Nov 01, 2007 6:10 pm    Post subject: Please look Reply with quote

http://demo.tixrus.us/distance.php

I have tweaked this every way I can think of and I don't know why it is not finding the
map object.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Thu Nov 01, 2007 9:56 pm    Post subject: this monologue is getting wanky Reply with quote

Someone talk to me please this monologue is getting wanky
I decided to subclass the GoogleAPI and add what I want on it.

EDITED:
DELETED bad code don't bother reading it, it's hideous, and now I have a version that works
_________________
Your online 24/7 box office
http://www.tixrus.us


Last edited by monotreme on Sun Nov 04, 2007 6:36 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Fri Nov 02, 2007 12:06 am    Post subject: OK. I see what's wrong Reply with quote

After pretty printing the onload code I can see that all that stuff was actually inside function calls.

markers has no data when I try to set up something I have to defer that to a function. Blech. OK... Monty I hope you release another official API with all this in it soon cuz subclassing is not a great solution when the class produces linear code. I may just go ahead and insert this in a version of the API. I can always revert to the official one if I totally crap it.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Sun Nov 04, 2007 6:31 pm    Post subject: Woohoo it works! Reply with quote

I overrided a bunch of the functions in GoogleMapAPI


Rather than using parent:: and painfully splicing my extra stuff in the output stream I just copied the code and modified it, because I think Monty should add this functionality to the official class.

This is VERY nice little bit of functionality that
I think will be useful for a lot of applications

Woohoo it works! After much fiddling Yea MONOTREME! pat pat.

check it out! http://demo.tixrus.us/distance.php

If you want my class PM me but I really think this functionality should go into the official API. If you don't use it you don't use it.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
nlstart
Smarty Rookie


Joined: 19 Oct 2007
Posts: 8

PostPosted: Mon Nov 05, 2007 8:04 am    Post subject: Reply with quote

Quite some monologue, monotreme! Seems to me you wrote a very welcomed addition!
Back to top
View user's profile Send private message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Mon Nov 05, 2007 3:24 pm    Post subject: woohoo an answer Reply with quote

I thrive on attention. Smile
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
drbigfresh
Smarty n00b


Joined: 15 Aug 2007
Posts: 3

PostPosted: Sun Dec 02, 2007 5:56 pm    Post subject: I would love to see your code.... Reply with quote

Would you mind posting it or emailing it to me. Trying to do the exact same thing and struggling with it.

Thanks.
Back to top
View user's profile Send private message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Sun Dec 02, 2007 7:24 pm    Post subject: I don't see how you attach here Reply with quote

I don't see there's a mechanism to post an attachment here so I will PM it to you if that's possible.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
robnjay
Smarty n00b


Joined: 13 Dec 2007
Posts: 1

PostPosted: Thu Dec 13, 2007 12:38 am    Post subject: Reply with quote

I want to use PHP to make a map that has the following functionality:

User can enter an address and get a marker on a map.

User can then zoom in close, and since Google Map Geocodes are often just a touch off, user can zoom in and click on the map to return geocodes for the location that was clicked on.

Then the user can regenerate the map to get a marker on the "corrected" position...

This would require functionality to return geocode to a textbox from the click event.

Would your enhancement be of use in this case?
Back to top
View user's profile Send private message
monotreme
Smarty Regular


Joined: 22 Feb 2004
Posts: 97
Location: USA

PostPosted: Thu Dec 13, 2007 12:55 am    Post subject: yes. Reply with quote

The user would need to drag the draggable marker to the exact spot, rather than click on the map, but effectively yes, it would fine tune a location. thats what i use it for.

PM me and give me your email and I'll send it to you.
_________________
Your online 24/7 box office
http://www.tixrus.us
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP