Changeset 84
- Timestamp:
- 07/11/07 17:03:28 (1 year ago)
- Files:
-
- branch/controllers/venues_controller.php (modified) (1 diff)
- branch/views/venues/admin_index.ctp (modified) (1 diff)
- branch/webroot/js/jquery.gmapp.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branch/controllers/venues_controller.php
r83 r84 23 23 $avg_lat = $avg_lat/$count; 24 24 $avg_lon = $avg_lon/$count; 25 $this->set('default', "center: [" . $avg_lat . "," . $avg_lon . "]");25 $this->set('default', $avg_lat . "," . $avg_lon); 26 26 $this->set('points', $points); 27 27 } branch/views/venues/admin_index.ctp
r83 r84 1 1 <h2>List Venues</h2> 2 2 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)});'));?> 4 4 5 5 <div id="gmap" style="float:left;width:800px;height:400px;"></div> branch/webroot/js/jquery.gmapp.js
r83 r84 35 35 latfield: "#VenueLatitude", 36 36 lngfield: "#VenueLongitude", 37 loadpoints: "/venues/", 38 savepoint: "save.php" 37 loadpoints: "/venues/" 39 38 },settings); 40 39 … … 42 41 { 43 42 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(); 46 45 var infoarea = settings.infoarea; 47 46 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); 49 48 50 49 switch(settings.control) 51 50 { 52 51 case "small": 53 map.addControl(new GSmallMapControl());52 this.GMap2.addControl(new GSmallMapControl()); 54 53 break; 55 54 case "large": 56 map.addControl(new GLargeMapControl());55 this.GMap2.addControl(new GLargeMapControl()); 57 56 break; 58 57 default: 59 map.addControl(new GSmallMapControl());58 this.GMap2.addControl(new GSmallMapControl()); 60 59 } 61 60 62 61 if (settings.showtype == true){ 63 map.addControl(new GMapTypeControl());62 this.GMap2.addControl(new GMapTypeControl()); 64 63 } 65 64 if (settings.showoverview == true){ 66 map.addControl(new GOverviewMapControl());65 this.GMap2.addControl(new GOverviewMapControl()); 67 66 } 68 67 /*jQuery(this).after('<p><strong>Google Map Application Version ' + version + '</strong></p>');*/ … … 70 69 /* Seach for the lat & lng of our address*/ 71 70 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); 73 72 }); 74 73 }); … … 76 75 }, 77 76 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( 80 80 address, 81 81 function(point){ … … 83 83 alert(address + " not found"); 84 84 } else { 85 map.setCenter(point,12);85 this.GMap2.setCenter(point,12); 86 86 var marker = new GMarker(point, {draggable: true}); 87 map.addOverlay(marker);87 this.GMap2.addOverlay(marker); 88 88 marker.openInfoWindowHtml("Lat: " + point.lat() + " Lng: " + point.lng()); 89 89 GEvent.addListener(marker, "dragend", function(){ … … 96 96 }, 97 97 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 } 100 112 } 101 113 } 102 114 103 115 jQuery.fn.gmapp = jQuery.gmapp.buildApp; 116 jQuery.fn.GMap2 = jQuery.gmapp.GMap2; 117 jQuery.fn.addPoint = jQuery.gmapp.addPoint;