Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved this issue by creating <strong>Custom Zoom buttons</strong> for my Map. </p> <p>Here is the code from my project:<br> <strong>Edit</strong>: Removed unnecessary and self explanatory common code </p> <p>your zoomControl function: </p> <pre><code>function zoomControl(map, div) { var controlDiv = div, control = this; // Set styles to your own pa DIV controlDiv.style.padding = '5px'; // Set CSS for the zoom in div. var zoomIncrease = document.createElement('div'); zoomIncrease.title = 'Click to zoom in'; // etc. // Set CSS for the zoom in interior. var zoomIncreaseText = document.createElement('div'); // Use custom image zoomIncreaseText.innerHTML = '&lt;strong&gt;&lt;img src="./images/plusBut.png" width="30px" height="30px"/&gt;&lt;/strong&gt;'; zoomIncrease.appendChild(zoomIncreaseText); // Set CSS for the zoom out div, in asimilar way var zoomDecreaseText = document.createElement('div'); // .. Code .. Similar to above // Set CSS for the zoom out interior. // .. Code .. // Setup the click event listener for Zoom Increase: google.maps.event.addDomListener(zoomIncrease, 'click', function() { zoom = MainMap.getZoom(); MainMap.setZoom(zoom+1); // Other Code parts }); // Setup the click event listener for Zoom decrease: google.maps.event.addDomListener(zoomDecrease, 'click', function() { zoom = MainMap.getZoom(); MainMap.setZoom(zoom-1); }); } </code></pre> <p>your initialize function:</p> <pre><code>function initializeMap() { var latlng = new google.maps.LatLng(38.6, -98); var options = { zoom : 5, center : latlng, mapTypeId : google.maps.MapTypeId.ROADMAP, // Other Options }; MainMap = new google.maps.Map(document.getElementById("google-map-canvas"), options); // The main part - Create your own Custom Zoom Buttons // Create the DIV to hold the control and call the zoomControl() var zoomControlDiv = document.createElement('div'), zoomLevelControl = new zoomControl(MainMap, zoomControlDiv); zoomControlDiv.index = 1; MainMap.controls[google.maps.ControlPosition.RIGHT_TOP].push(zoomControlDiv); } </code></pre> <p>Hope it helps</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload