Add bookmark to Google map

0

Depending on the post you made at Disable zoom google maps does not work

@Samir Braga replied to the following code:

 <!doctype html>
<html lang="pt,BR">
<head>
    <meta charset="UTF-8">
    <title>API Google Maps V3</title>

    <!-- Inicialização do mapa -->
    <script>
    function initialize() {

  // Exibir mapa;
  var myLatlng = new google.maps.LatLng(-8.0631495, -34.87131120000004);
  var mapOptions = {
    zoom: 17,
    center: myLatlng,
    panControl: false, 
draggable: false,
    zoomControl: false,
    scrollwheel: false,
    // mapTypeId: google.maps.MapTypeId.ROADMAP
    mapTypeControlOptions: {
      mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style']
    }
  }
  // Exibir o mapa na div #mapa;
  var map = new google.maps.Map(document.getElementById("mapa"), mapOptions);

  // crio um objeto passando o array de estilos (styles) e definindo um nome para ele;
  var styledMap = new google.maps.StyledMapType(styles, {
    name: "Mapa Style"
  });
  // Aplicando as configurações do mapa
  map.mapTypes.set('map_style', styledMap);
  map.setMapTypeId('map_style');

}

// Função para carregamento assíncrono
function loadScript() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.googleapis.com/maps/api/js?key=AIzaSyDeHb17So0QupSGO_d6b8X-OyvJ32UQehs&sensor=true&callback=initialize";
  document.body.appendChild(script);
}

window.onload = loadScript;
</script>

    <style>
        #mapa{
            width: 100%;
            height: 500px;
            border: 1px solid #ccc;
        }
    </style>

</head>

<body>
    <div id="mapa"></div>
</body>
</html>

But my question would be about his response to the code. I tried to modify here using this suggestion and it worked, it was very good even, but the pin does not appear in the place. Just the map with my coordinate to the center, the marker in the exact location does not appear ... so is there any parameter that allows marking to be included?

I tried to add "marker" with the coordinate or something and I could not.

Thank you.

    
asked by anonymous 13.01.2016 / 21:33

1 answer

0

Try something similar to this:

function initialize() {

  var myLatlng = new google.maps.LatLng(28.3852338, -81.5638743);
  var mapOptions = {
    zoom: 15,
    center: myLatlng,
    panControl: false,
    draggable: false,
    zoomControl: false,
    scrollwheel: false,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControlOptions: {
      mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style'],
    },
  }

  var map = new google.maps.Map(document.getElementById("mapa"), mapOptions);
  var marker = new google.maps.Marker({
    position: myLatlng,
    map: map
  });


}

function loadScript() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.googleapis.com/maps/api/js?key=AIzaSyDeHb17So0QupSGO_d6b8X-OyvJ32UQehs&sensor=true&callback=initialize";
  document.body.appendChild(script);
}

window.onload = loadScript;
<style>
  #mapa {
    width: 300px;
    height: 300px;
    border: 1px solid #ccc;
  }
</style>

<div id="mapa"></div>
    
13.01.2016 / 22:04