Assembla home | Assembla project page
 

Changeset 84

Show
Ignore:
Timestamp:
07/11/07 17:03:28 (1 year ago)
Author:
digitalspaghetti
Message:

More changes to GMapp plugin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branch/controllers/venues_controller.php

    r83 r84  
    2323                $avg_lat = $avg_lat/$count; 
    2424                $avg_lon = $avg_lon/$count; 
    25                 $this->set('default', "center: [" . $avg_lat . "," . $avg_lon . "]"); 
     25                $this->set('default', $avg_lat . "," . $avg_lon); 
    2626                $this->set('points', $points); 
    2727        } 
  • branch/views/venues/admin_index.ctp

    r83 r84  
    11<h2>List Venues</h2> 
    22 
    3 <?php e($javascript->codeBlock('$j().ready(function(){$j("#gmap").gmapp({' . $default . ', zoom: 9});});'));?> 
     3<?php e($javascript->codeBlock('$j().ready(function(){$j("#gmap").gmapp(); $j("#gmap")[0].GMap2.setCenter(new GLatLng(' . $default . '), 2)});'));?> 
    44 
    55<div id="gmap" style="float:left;width:800px;height:400px;"></div> 
  • branch/webroot/js/jquery.gmapp.js

    r83 r84  
    3535                        latfield: "#VenueLatitude", 
    3636                        lngfield: "#VenueLongitude", 
    37                         loadpoints: "/venues/", 
    38                         savepoint: "save.php" 
     37                        loadpoints: "/venues/" 
    3938                },settings); 
    4039                 
     
    4241                { 
    4342                        return this.each(function(){ 
    44                                 var map = new GMap2 (this); 
    45                                 var geocoder = new GClientGeocoder(); 
     43                                this.GMap2 = new GMap2(this); 
     44                                GGeocoder = new GClientGeocoder(); 
    4645                                var infoarea = settings.infoarea; 
    4746                                 
    48                                 map.setCenter(new GLatLng(settings.center[0],settings.center[1]),settings.zoom,settings.maptype); 
     47                                this.GMap2.setCenter(new GLatLng(settings.center[0],settings.center[1]),settings.zoom,settings.maptype); 
    4948                                 
    5049                                switch(settings.control) 
    5150                                { 
    5251                                        case "small": 
    53                                                 map.addControl(new GSmallMapControl()); 
     52                                                this.GMap2.addControl(new GSmallMapControl()); 
    5453                                                break; 
    5554                                        case "large": 
    56                                                 map.addControl(new GLargeMapControl()); 
     55                                                this.GMap2.addControl(new GLargeMapControl()); 
    5756                                                break; 
    5857                                        default: 
    59                                                 map.addControl(new GSmallMapControl()); 
     58                                                this.GMap2.addControl(new GSmallMapControl()); 
    6059                                } 
    6160                         
    6261                                if (settings.showtype == true){ 
    63                                         map.addControl(new GMapTypeControl()); 
     62                                        this.GMap2.addControl(new GMapTypeControl()); 
    6463                                } 
    6564                                if (settings.showoverview == true){ 
    66                                         map.addControl(new GOverviewMapControl()); 
     65                                        this.GMap2.addControl(new GOverviewMapControl()); 
    6766                                } 
    6867                                /*jQuery(this).after('<p><strong>Google Map Application Version ' + version + '</strong></p>');*/ 
     
    7069                                /* Seach for the lat & lng of our address*/ 
    7170                                jQuery('#findaddress').bind('click', function(){ 
    72                                         jQuery.gmapp.searchAddress(jQuery(settings.geocode).attr('value'), map, geocoder, infoarea); 
     71                                        jQuery.gmapp.searchAddress(jQuery(settings.geocode).attr('value'), GGeocoder, infoarea); 
    7372                                });      
    7473                        }); 
     
    7675        }, 
    7776         
    78         searchAddress : function(address, map, geocoder, infoarea) { 
    79                 geocoder.getLatLng( 
     77        /* FIXME: Search for an address or postcode, return the GLatLng and center map.  Then add a dragable marker*/ 
     78        searchAddress : function(address, GGeocoder, infoarea) { 
     79                GGeocoder.getLatLng( 
    8080                address, 
    8181                function(point){ 
     
    8383                                alert(address + " not found"); 
    8484                        } else { 
    85                                 map.setCenter(point,12); 
     85                                this.GMap2.setCenter(point,12); 
    8686                                var marker = new GMarker(point, {draggable: true}); 
    87                                 map.addOverlay(marker); 
     87                                this.GMap2.addOverlay(marker); 
    8888                                marker.openInfoWindowHtml("Lat: " + point.lat() + " Lng: " + point.lng()); 
    8989                                GEvent.addListener(marker, "dragend", function(){ 
     
    9696        }, 
    9797         
    98         showAllPoints : function (map, settings) { 
    99                 jQuery.get(settings.loadpoints); 
     98        /* Returns the map being used so Google methods can be accessed*/ 
     99        /* Example: $("#gmap").GMap2().setCenter(new GLatLng(55.958387,-3.162367), 10);*/ 
     100        GMap2 : function() { 
     101                return this[0].GMap2; 
     102        }, 
     103         
     104        /* FIXME: Add's a point to the current map (this function currently does not give the desired results)*/ 
     105        /* Example: $("#gmap").addPoint({pointlat:55.958387,pointlnt:-3.162367, pointhtml:"My Point", isdraggable:true});*/ 
     106        addPoint : function(pointlat, pointlng, pointhtml, isdraggable,centermap) { 
     107                var marker = new GMarker(new GLatLng(pointlat,pointlng), { draggable: isdraggable } ); 
     108                return this[0].GMap2.addOverlay(marker); 
     109                if (centermap == true) { 
     110                        return this[0].GMap2.setCenter(new GLatLng(pointlat,pointlng),10); 
     111                } 
    100112        } 
    101113} 
    102114 
    103115jQuery.fn.gmapp = jQuery.gmapp.buildApp; 
     116jQuery.fn.GMap2 = jQuery.gmapp.GMap2; 
     117jQuery.fn.addPoint = jQuery.gmapp.addPoint;