Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Hack for GoogleMapAPI.class.php v. 2.3

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
JohanSoderstrom
Smarty n00b


Joined: 10 Jul 2007
Posts: 3

PostPosted: Tue Jul 10, 2007 7:45 am    Post subject: Hack for GoogleMapAPI.class.php v. 2.3 Reply with quote

Hi.

I appologize if this has already been said, but I didn't have time to read the whole forum to find it...

I am using this file together with MisterEstate and had to make some alterations to it in order to get it to work as intended. I do not know if these problems are due to MisterEstate or GoogleMapAPI.class.php. But I will post them here for the developers to see anyway...

1. Problem with "," and "."

There was some problems with how coordinates were handeled, so I implemented the following

//Hack for V-Dala.se
$this->center_lat = number_format($this->center_lat, 6, '.', '');
$this->center_lon = number_format($this->center_lon, 6, '.', '');
//End of hack
if(isset($this->center_lat) && isset($this->center_lon)) {
$_output .= sprintf('map.setCenter(new GLatLng(%s, %s), %s, %s);', $this->center_lat, $this->center_lon, $this->zoom, $this->map_type) . "\n";
}



2. Centering on the current marker

Using the code above the map will center wrong. This might be a feature but I could not access $_marker in there, so I hacked on..

//Hack for V-Dala.se
$this->center_lat = number_format($this->center_lat, 6, '.', '');
$this->center_lon = number_format($this->center_lon, 6, '.', '');
//End of hack
if(isset($this->center_lat) && isset($this->center_lon)) {
// $_output .= sprintf('map.setCenter(new GLatLng(%s, %s), %s, %s);', $this->center_lat, $this->center_lon, $this->zoom, $this->map_type) . "\n";
}

and also

//Hack for V-Dala.se
if(isset($this->center_lat) && isset($this->center_lon)) {
// $_output .= sprintf('map.setCenter(new GLatLng(%s, %s), %s, %s);', $this->center_lat, $this->center_lon, $this->zoom, $this->map_type) . "\n";
$_output .= sprintf('map.setCenter(new GLatLng(%s, %s), %s, %s);', $_marker['lat'], $_marker['lon'], $this->zoom, $this->map_type) . "\n";
}
//End of hack

I could access $_marker there, so I moved the statement there.

3. Javascript error

I still got an error from javascript (but everything was working) so I replaced

//Hack for V-Dala.se
if($this->sidebar) {
// $_output .= sprintf('document.getElementById("%s").innerHTML = "<ul class=\"gmapSidebar\">"+ sidebar_html +"</ul>";', $this->sidebar_id) . "\n";
$_output .= "\n";
}
//End of hack

I have no idea of how this changes the javascript, but it works like a charm for me... I guess that is if you want the sidebar (with directions and so on) but as I do not use nor need it I can easily uncomment it...

I hope that this helps the developers, the reason for the ugly hacks and the quick post is that I am on a deadline here... cheers!

~Johan

Feel free
Back to top
View user's profile Send private message
JohanSoderstrom
Smarty n00b


Joined: 10 Jul 2007
Posts: 3

PostPosted: Wed Aug 01, 2007 1:40 pm    Post subject: Feedback? Reply with quote

No feedback on this? Was I all wrong in this...???
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Aug 01, 2007 3:05 pm    Post subject: Reply with quote

What is MisterEstate, and what was the problem with "." vs "," in the first place? You can't control what is passed to Google maps?

Please indicate clearly the problem you are addressing instead of just posting code that we have to guess at. Thanks!
Back to top
View user's profile Send private message Visit poster's website
JohanSoderstrom
Smarty n00b


Joined: 10 Jul 2007
Posts: 3

PostPosted: Wed Aug 01, 2007 3:23 pm    Post subject: Reply with quote

MisterEstate is a plugin to Joomla that uses thia API t display Goole maps...

Ok, it might have been a bit hectic writing that, I was trying to meet a deadline.

When setting the coordinates to display I set them as (5.67, 4.56) for example. Somewhere along the lines of the code this got changed to (5,67, 4,56) - as I did not write joomla, not MisterEstate nor this API I do not know where this happened. It could potentially be due to different locales beeing set (I live in Sweden). This obvioulsy made the Googlemaps API not working as intended - therefore I had to change the numberformat.

Again, I am not sure of the cause of this, but this fixed it. My initial guess is having different locales set and that can (??) affect how ph is passing the numbers between classes.


The second part of the code (2) and (3) might be problems with the joomla component MisterEstate and how it interacts with the google maps api - although I thought it could be worth posting here in case someone bumpend in to similar problems and needed to fix them. In any case - a safe fallback would be to let Google Maps center on the marker if no other center is defined.

So, to conlculde. Without being certain of the reason I think it could be wise to include the number formatting in (1). (2) and (3) is just a fallback to get the Google Maps API to center correctly on the marker if no centering is specified (if I remember correctly - I cannot remember it exactly now)...

Allt he best,
Johan
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Aug 01, 2007 3:48 pm    Post subject: Reply with quote

Actually, it looks like all these issues are already addressed in CVS. I'll get a new release out. In the meantime, you can use the CVS checkout.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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