codesite-noreply at google.com
2009-Oct-08 13:10 UTC
[Mapstraction] [mapstraction] r45 committed - ...
Revision: 45 Author: freyfogle Date: Thu Oct 8 06:09:49 2009 Log: - expanded example for googlev3 - getZoomLevelForBoundingBox working - jslint passing (final comma is death to MSIE *sigh*) http://code.google.com/p/mapstraction/source/detail?r=45 Modified: /trunk/examples/googlev3.html /trunk/source/mxn.googlev3.core.js ======================================--- /trunk/examples/googlev3.html Sun Sep 20 06:07:56 2009 +++ /trunk/examples/googlev3.html Thu Oct 8 06:09:49 2009 @@ -12,9 +12,10 @@ <script type="text/javascript"> //<![CDATA[ + var m; function initialize() { // create mxn object - var m = new mxn.Mapstraction(''mapdiv'',''googlev3''); + m = new mxn.Mapstraction(''mapdiv'',''googlev3''); m.addControls({zoom:''small''}); var latlon = new mxn.LatLonPoint(51.53468413093941, -0.09026169776916504) @@ -22,10 +23,15 @@ // put map on page m.setCenterAndZoom(latlon, 16); - // add a marker - // var marker = new mxn.Marker(latlon); - // m.addMarker(marker,true); - } + //add a marker + var marker = new mxn.Marker(latlon); + m.addMarker(marker,true); + } + + function changetohybrid(){ + m.setMapType(mxn.Mapstraction.HYBRID); + } + //]]> </script> @@ -36,6 +42,7 @@ <tr><td><div id="mapdiv"></div></td> </tr> </table> +<a href=''#'' onclick=''changetohybrid();''>change to hybrid</a> </center> </body> </html> ======================================--- /trunk/source/mxn.googlev3.core.js Wed Oct 7 16:51:49 2009 +++ /trunk/source/mxn.googlev3.core.js Thu Oct 8 06:09:49 2009 @@ -8,7 +8,7 @@ // by default no controls and road map var myOptions = { disableDefaultUI: true, - mapTypeId: google.maps.MapTypeId.ROADMAP, + mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(element, myOptions); @@ -177,13 +177,17 @@ }, getZoom: function() { - var map = this.maps[this.api]; - return map.getZoom(); + var map = this.maps[this.api]; + return map.getZoom(); }, getZoomLevelForBoundingBox: function( bbox ) { var map = this.maps[this.api]; - throw ''Not implemented''; + var sw = bbox.getSouthWest().toProprietary(this.api); + var ne = bbox.getNorthEast().toProprietary(this.api); + var gLatLngBounds = new google.maps.LatLngBounds(sw, ne); + map.fitBounds(gLatLngBounds); + return map.getZoom(); }, setMapType: function(type) {