/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
if (GBrowserIsCompatible()) { //copyright && copyright collection var copyOSM = new GCopyrightCollection('<a href="http://www.openstreetmap.org/">OpenStreetMap</a>'); // apply the statement to the whole world copyOSM.addCopyright(new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), // region 0, // minimum zoom level ' ' // no additional copyright message, but empty string hides entire copyright )); // create a tile layer var tilesMapnik = new GTileLayer( copyOSM, // copyright statement 7, // minimum zoom level 18, // maximum zoom level { // options includes URL template for addressing individual tiles // X, Y, Z respectively are tile coordinates for lattitude and longitude, // and the zoom level tileUrlTemplate: 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', isPng: true // otherwize assumes GIF images } ); //map type var mapMapnik = new GMapType( [tilesMapnik], // list of layers G_NORMAL_MAP.getProjection(), // borrow the Mercator projection from the standard map 'OSM' // name should be short enough to fit in button ); var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37, 0), 4); map.addMapType(mapMapnik); map.addControl(new GLargeMapControl()); map.addControl(new GOverviewMapControl()); map.addControl(new GScaleControl()); map.setMapType(mapMapnik); map.enableDoubleClickZoom(); map.enableContinuousZoom(); map.enableScrollWheelZoom(); }