I can’t draw a Polygon on Google Maps

Asked

Viewed 61 times

0

I’m trying to square it with the coordinates, but it won’t show. There is no error in the browser, the map is created normally, only the square does not appear:

var map;

function initialize() {
    var latlng = new google.maps.LatLng(-21.723254, -49.356317);

    var options = {
        zoom:30,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.SATELLITE
    };

    map = new google.maps.Map(document.getElementById('map'), options);
    var geocoder = new google.maps.Geocoder();

    var princiCoords = [
        new google.maps.LatLng(-21.724394, -49.356391),
        new google.maps.LatLng(-21.724172, -49.356479),
        new google.maps.LatLng(-21.724044, -49.356040),
        new google.maps.LatLng(-21.724257, -49.355960)
    ];

    var princiPolygon = new google.maps.Polygon({
        // Coordenadas do seu objeto
        paths: princiCoords,
        // Cor do da linha
        strokeColor: '#E12D93',
        // Opacidade da linha
        strokeOpacity: 0.8,
        // Espessura da linha
        strokeWeight: 4,
        // Cor de preenchimento do objeto
        fillColor: '#942E7C',
        // Opacidade do preenchimento
        fillOpacity: 0.35
    });

    princiPolygon.setMap(map);
}

initialize();
  • Hello Hugo, could edit your question and describe your problem?

  • In the command to load the Google Maps API script you have included the parameter libraries=geometry, to include these geometry functions?

  • No, it has to be after Key ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.