如何通过google.maps.Geocoder()的Google API密钥.geocode()

时间:2018-04-30 15:24:57

标签: javascript asp.net google-maps

请为我提供以下代码的正确解决方案

如何通过Google API密钥

function load_map_from_address(mapid, address) {
        // check if gps has been locally cached.     
        geocoder = new google.maps.Geocoder();
        //alert(geocoder);
        var geocoderAPIKey = 'geocoderAPIKey ';
        geocoder.geocode({ 'address': address }, function (results, status) {
            //alert(status);
            if (status == "OK") {

                var gps = results[0].geometry.location;
                create_map(gps.lat(), gps.lng(), mapid);
            }
            else {
                $('#' + mapid).html('<div class="map_canvas_text "><h4>address not found</h4></div>').show();

            }
        });
    }

1 个答案:

答案 0 :(得分:0)

您可以在添加Google地图js时提及它。就像是 。

go-google-map js?key = yourApiKey

在你的脚本标签