V
V
VadinTrueStudio2019-05-24 16:15:36
JavaScript
VadinTrueStudio, 2019-05-24 16:15:36

How to install google maps via api on the site?

Can't install google maps. Here is the callback function

var marker;

function shopMap() {
    var shop = $('#shops-info__map').attr('data-geo').split(',');
    var map = new google.maps.Map(document.getElementById('shops-info__map'), {
        center: new google.maps.LatLng(shop[0], shop[1]),
        //scrollwheel: false,
        disableDefaultUI: false,
        mapTypeControl: false,
        streetViewControl: false,
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    var customMapType = new google.maps.StyledMapType([{"stylers": [{"saturation": -100}]}, {
            "featureType": "poi",
            "stylers": [{"visibility": "off"}]
        }],
        {name: 'Custom Stysle'});
    var customMapTypeId = 'custom_style';
    map.mapTypes.set(customMapTypeId, customMapType);
    map.setMapTypeId(customMapTypeId);

    var marker_image = '/static/images/bml_map.svg';
    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(shop[0], shop[1]),
        map: map,
        icon: marker_image
    });
    var text = $('#shops-info__map').attr('data-text');
    var infowindow = new google.maps.InfoWindow({
        content: text
    });
    marker.addListener('click', function () {
        infowindow.open(map, marker);
    });
}

This is how it is written in html
script(src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDy9eQx5kMEARWLXqslJFeGxvIP-GrEG34&callback=shopMap")

From several sources we learned that the api is paid, while others claim that it is not. Is it so

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bubble_in_space, 2019-05-24
@VadinTrueStudio

Api is paid when a certain number of requests per month
is reached, if you increase the limit, then money will begin to be debited.
But when you receive an api key, you will have to pay (like $ 1), which will be returned to you within 1 day, this is done to check the card whether it exists on In fact,
at least that's how I understood the documentation on the Google page
(I can't help with the code)

E
Evgeny Zaletsky, 2019-05-24
@JZ_52

Maybe this? If not , then I misunderstood your question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question