Advertisement:

Author Topic: Google Map - Rewrite  (Read 5313 times)

kingsult

  • Premium
  • Full Member
  • *****
  • Posts: 204
Google Map - Rewrite
« on: January 12, 2011, 06:41:05 pm »
Hi,

I wanted to share the map.php file I have implemented. I had some address recognition issues in the beginning. And started to play around...

I have changed some things:
Added Map Controls (Zoom, ... ) and Map Type (map, sattelite, ...)
Added a new variable to show item name in the info bubble, instead of the address.
Quote
<script type="text/javascript">
if(GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("itemMap"));
    var geocoder = new GClientGeocoder();
   map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    var title_ad_googlemap = "<?= $item['s_title'] ?>";
    var city_ad_googlemap = "<?= $item['s_city'] ?>";
   var description_ad_googlemap = title_ad_googlemap + ', ' + city_ad_googlemap;
   
   
    function showAddress(address, region) {
        geocoder.getLatLng(
            address,
            function(point) {
            if (!point) {
                var geocoderRegion = new GClientGeocoder();
                geocoderRegion.getLatLng(
                    region,
                    function(point) {
                        if (!point) {
                            alert(region + " not found");
                        } else {
                            map.setCenter(point, 13);
                            var marker = new GMarker(point);
                            map.addOverlay(marker);
                            //marker.openInfoWindowHtml(region);
                        }
                    }
                );
                } else {
                    map.setCenter(point, 13);
                    var marker = new GMarker(point);
                    map.addOverlay(marker);
                    marker.openInfoWindowHtml(description_ad_googlemap);
                }
            }
        );
    }
}

Juan Ramón

  • Osclass Developer
  • Hero Member
  • *****
  • Posts: 2382
Re: Google Map - Rewrite
« Reply #1 on: January 12, 2011, 06:49:36 pm »
Great! I save this code and we'll update the google maps plugin :) I'll will put you as creator also ;)

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 4689
Re: Google Map - Rewrite
« Reply #2 on: January 12, 2011, 10:29:41 pm »
Hi kingsult,

That is great. I already merge your code with the existing one. You could take a look to our new git repository for plugins :

https://github.com/osclass/osclass-plugins


If something is wrong, please tell us.

Thanks!

kittymy

  • Newbie
  • *
  • Posts: 4
Re: Google Map - Rewrite
« Reply #3 on: February 21, 2011, 06:48:38 am »
https://github.com/osclass/osclass-plugins

how can install all plusgins

code monkey

  • Full Member
  • ***
  • Posts: 204
Re: Google Map - Rewrite
« Reply #4 on: April 05, 2011, 10:38:48 am »
Another idea is to use the Google Maps embed link.
When someone clicks on address hyperlink, open the map in overlay.

Example: http://bit.ly/gWpTQp (click address).

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 4689
Re: Google Map - Rewrite
« Reply #5 on: April 05, 2011, 11:29:13 am »
Amazing!!

I will work on an update of the plugin to allow the embed link ;)

Juan Ramón

  • Osclass Developer
  • Hero Member
  • *****
  • Posts: 2382
Re: Google Map - Rewrite
« Reply #6 on: April 05, 2011, 12:41:27 pm »
Are you using colorbox to open the map in a overlay? Nice!

code monkey

  • Full Member
  • ***
  • Posts: 204
Re: Google Map - Rewrite
« Reply #7 on: April 05, 2011, 01:30:43 pm »
Are you using colorbox to open the map in a overlay? Nice!

Yep  ;)

kingsult

  • Premium
  • Full Member
  • *****
  • Posts: 204
Re: Google Map - Rewrite
« Reply #8 on: April 05, 2011, 05:03:43 pm »
Love it !