我正在尝试使用mocha测试我的react应用程序。我在我的应用程序中使用google maps api。当我运行我的mocha测试时,我得到一个错误"ReferenceError: google is not defined“。在我的应用程序中,我可以使用API,因为我在我的html中包含了以下脚本标记。
<script src="https://maps.googleapis.com/maps/api/js?v=3&libraries=geometry,places,drawing&key=KEY></script>.
Mocha在n
我在我的React组件中使用了google对象(例如新的google.maps.places.PlacesService())。这是我想使用Story book测试/优化的组件。在故事书配置中,我尝试调用‘-head.html’中的googapis作为脚本,指向“googapi...
然而,当故事书加载/启动时,我的react组件抛出了一个异常"ReferenceError: google is not defined“。看起来,上面的api没有正确调用。
感谢您的帮助。
谢谢!
请帮助我在google的街道视图中添加一个标记,但是当我把它放在没有工作的地方,我得到了一个未定义的ReferenceError:地图没有定义
这是标记变量
var cafe = new google.maps.LatLng(34.935196, -107.539546);
下面是设置标记的代码
var cafeMarker = new google.maps.Marker({
position: cafe,
map: map,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=ca
我似乎不知道如何启动基于google脚本GET请求的函数。
export class Map extends Component {
constructor(props) {
super(props);
this.state = {};
};
componentDidMount = function () {
console.log(google); // Uncaught ReferenceError: google is not defined
};
scriptInitialized = fun
我试图使用google将我的地址转换为经度和纬度,然后在页面上显示地图。
只是一个说明im使用PHP/Laravel从DB检索地址。所以,尽管这是纽约的一个硬编码值,但在我完成这项工作后,它将是动态的。
<div id="map" style="height:250px"></div>
Javascript
<script>
var geocoder = new google.maps.Geocoder();
var address = "new york";
geocoder.g
我的身体里有以下代码
<div id="searchresult" onmouseover="changeMarker(marker1)">
头上还有下面的
function changeMarker(marker) {
alert(marker);
}
现在,当我在div上鼠标操作时,我在javascript控制台中得到了以下错误
Uncaught ReferenceError: marker1 is not defined
如果下面是函数不接受变量的情况,则调用警报框。
function changeMarker() {
aler
当用户将鼠标放在div上时,我使用下面的代码使地图上的标记发生更改。Marker1在初始化()中定义如下:
var marker1 = new google.maps.Marker({
position: new google.maps.LatLng(1.288693,103.846733),
map: map,
icon: "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=1|c41200|fff
我想做的事
在地图上放置一个标记,并计算标记与地图上静态位置之间的距离。
如果距离大于1000米,我将显示不可用的地址。
问题描述
无法在UseEffect内访问谷歌。
我正确地加载了脚本并遵循了
window.google在onMapClick函数中是可用的,但在我的索引组件或useEffect钩子中的任何地方都不能使用。
我怎样才能访问它?其他一切都很好
Unhandled Runtime Error
ReferenceError: google is not defined
import React, { useRef, useState, u
我正在创建一个使用react-google-maps的web,我收到了一堆未定义的错误。我是react/js世界的新手,所以任何帮助都将不胜感激。下面是确切的错误:
Failed to compile.
./src/App.js
Line 23: 'lifecycle' is not defined no-undef
Line 25: 'google' is not defined no-undef
Line 28: 'google' is not defined no-undef
Line 29: &
我试图遍历一些坐标集,在Google地图上绘制向量,但似乎无法正确地使用语法,以便将这些坐标放入:
var buildingCoords1 = [
new google.maps.LatLng(51.49609,-0.27609),
new google.maps.LatLng(51.49604,-0.27502),
new google.maps.LatLng(51.49586,-0.27504),
new google.maps.LatLng(51.49588,-0.27533),
new google.maps.LatLng(51.49563,-0
new MapLabel以前在我所有的程序中都能用,但现在不能用了:
var mapLabelA = new MapLabel(
{
text: ' From Wilkes or Henlow** ',
position: new google.maps.LatLng(49.796600, -97.196000),
map: map,
fontSize: 13,
align: 'right'
}
);
为什么我的maplabels会停止工作?
Failed to lo
我在CoffeeScript中得到了一个奇怪的行为:从加载的脚本(&callback=initMap)正确地调用了initMap函数,但是在initMap()的最后一行触发了一个错误
# Declare a global function
@initMap = ->
restaurantLocation =
lat: $('#restaurant-map').data("lat")
lng: $('#restaurant-map').data("lng")
map = new (google.