1

I've this simple map built on Google Maps APi v3 ....

<html>
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0">
    <meta charset="utf-8">
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script>
      var map;
      function initMap() {



      var myOptions = {
          zoom: 8,
          center: {lat: -34.397, lng: 150.644},
          mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("map"), myOptions);


      //### Add a button on Google Maps ...
      var controlMarkerUI = document.createElement('DIV');
      controlMarkerUI.style.cursor = 'pointer';
      controlMarkerUI.style.backgroundImage = "url(http://localhost/marker.png)";
      controlMarkerUI.style.height = '28px';
      controlMarkerUI.style.width = '25px';
      controlMarkerUI.style.top = '11px';
      controlMarkerUI.style.left = '120px';
      controlMarkerUI.title = 'Click to set the map to Home';
      //myLocationControlDiv.appendChild(controlUI);

      map.controls[google.maps.ControlPosition.LEFT_TOP].push(controlMarkerUI);

      //### Add a button on Google Maps ...
      var controlTrashUI = document.createElement('DIV');
      controlTrashUI.style.cursor = 'pointer';
      controlTrashUI.style.backgroundImage = "url(http://localhost/trash.png)";
      controlTrashUI.style.height = '28px';
      controlTrashUI.style.width = '25px';
      controlTrashUI.style.top = '11px';
      controlTrashUI.style.left = '150px';
      controlTrashUI.title = 'Click to set the map to Home';
      //myLocationControlDiv.appendChild(controlUI);

      map.controls[google.maps.ControlPosition.LEFT_TOP].push(controlTrashUI);
}

    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=<PUT_YOUR_API-HERE>&callback=initMap"
    async defer></script>
  </body>
</html>

The map result is the follow

enter image description here

In my code the styles for the two buttons, marker and trash, are set in a way that shoud be aside the "Satellite" button in this manner

enter image description here

Why my style settings are not kept?

Suggestions / examples?

  • 1
    I think you would get more responses over at Stack Overflow judging by your question and your tags. – danagerous Jun 14 '17 at 23:11
1

https://developers.google.com/maps/documentation/javascript/3.exp/reference#ControlPosition

map.controls[google.maps.ControlPosition.TOP_LEFT].push(controlTrashUI);

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

0

There are a lot of map markers and store locators on the market for free that you can use ready-made. you don't have to bother with the customization of google maps API. In this article, you can find a list with some of the best ones https://nearplace.com/blog/best-wordpress-store-locator-plugin-free-paid/

0

display:inline-block float:left

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.