codesite-noreply at google.com
2010-Feb-11 00:36 UTC
[Mapstraction] [mapstraction] r74 committed - Updated events code in Google V3 and CloudMade
Revision: 74 Author: duvander Date: Wed Feb 10 16:35:50 2010 Log: Updated events code in Google V3 and CloudMade http://code.google.com/p/mapstraction/source/detail?r=74 Modified: /trunk/source/mxn.cloudmade.core.js /trunk/source/mxn.core.js /trunk/source/mxn.googlev3.core.js /trunk/source/mxn.js ======================================--- /trunk/source/mxn.cloudmade.core.js Thu Jan 14 13:41:14 2010 +++ /trunk/source/mxn.cloudmade.core.js Wed Feb 10 16:35:50 2010 @@ -2,7 +2,7 @@ Mapstraction: { - init: function(element, api) { + init: function(element, api) { var me = this; var cloudmade = new CM.Tiles.CloudMade.Web({key: cloudmade_key}); this.maps[api] = new CM.Map(element, cloudmade); @@ -21,6 +21,12 @@ if ( location ) { me.clickHandler(location.lat(),location.lng(),location,me); } + }); + CM.Event.addListener(this.maps[api], ''dragend'', function() { + me.endPan.fire(); + }); + CM.Event.addListener(this.maps[api], ''zoomend'', function() { + me.changeZoom.fire(); }); }, ======================================--- /trunk/source/mxn.core.js Wed Jan 27 15:57:47 2010 +++ /trunk/source/mxn.core.js Wed Feb 10 16:35:50 2010 @@ -396,8 +396,6 @@ if (this.maps[this.api] === undefined) { init.apply(this); - this.setCenterAndZoom(center,zoom); - for (var i = 0; i < this.markers.length; i++) { this.addMarker(this.markers[i], true); } @@ -405,6 +403,8 @@ for (var j = 0; j < this.polylines.length; j++) { this.addPolyline( this.polylines[j], true); } + + this.setCenterAndZoom(center,zoom); } else { ======================================--- /trunk/source/mxn.googlev3.core.js Mon Dec 14 17:04:05 2009 +++ /trunk/source/mxn.googlev3.core.js Wed Feb 10 16:35:50 2010 @@ -3,13 +3,38 @@ Mapstraction: { init: function(element, api){ - var me = this; + var me = this; if ( google && google.maps ){ - // by default no controls and road map + // by default add road map and no controls var myOptions = { disableDefaultUI: true, - mapTypeId: google.maps.MapTypeId.ROADMAP + mapTypeId: google.maps.MapTypeId.ROADMAP, + mapTypeControl: false, + mapTypeControlOptions: null, + navigationControl: false, + navigationControlOptions: null }; + + // find controls + if (!this.addControlsArgs && loadoptions.addControlsArgs) { + this.addControlsArgs = loadoptions.addControlsArgs; + } + if (this.addControlsArgs) { + if (this.addControlsArgs.zoom) { + myOptions.navigationControl = true; + if (this.addControlsArgs.zoom == ''small'') { + myOptions.navigationControlOptions = {style: google.maps.NavigationControlStyle.SMALL}; + } + if (this.addControlsArgs.zoom == ''large'') { + myOptions.navigationControlOptions = {style: google.maps.NavigationControlStyle.ZOOM_PAN}; + } + } + if (this.addControlsArgs.map_type) { + myOptions.mapTypeControl = true; + myOptions.mapTypeControlOptions = {style: google.maps.MapTypeControlStyle.DEFAULT}; + } + } + var map = new google.maps.Map(element, myOptions); // deal with click @@ -218,7 +243,7 @@ getBounds: function () { var map = this.maps[this.api]; - var gLatLngBounds = map.getBounds(); + var gLatLngBounds = map.getBounds(); var sw = gLatLngBounds.getSouthWest(); var ne = gLatLngBounds.getNorthEast(); return new mxn.BoundingBox(sw.lat(), sw.lng(), ne.lat(), ne.lng());