- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对我的 map 做了一些操作(不确定是什么),现在正在运行的函数抛出以下错误:
Invalid value for property <travelMode>: undefined line 16 main.js
我做的最后一件事是添加以下行:
directionsDisplay.setPanel(document.getElementById("directions"));
这样我就可以在 div 中显示方向详细信息。这是我的引用代码:
// This function sets-up and initiates the Google maps interface
function load_map() {
startLatLng = new google.maps.LatLng(52.485809,-1.888783);
// create a new Google latLang marker object with co-ords for
//the start location
var config = {
zoom: 5,
center: startLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// create a JASON object to store map configruation
map = new google.maps.Map(document.getElementById("map"), config);
// intilise the map passing the display divs id and the config
// object
var startMarker = new google.maps.Marker({
position: startLatLng,
map: map
})
startMarker.setIcon('/imgs/startMarker.png');
// create a new marker object for start (passing anonomus JASON
// config object)
startMarker.setMap(map);
// Add the marker to the map
geocodeAddress("ARM Ltd Rockingham Court 152 Rockingham Street Sheffield Great Britain");
geocodeAddress("Centrum House 36 Station Road Egham Surrey");
geocodeAddress("Pipers Way Swindon United Kingdom");
// call the geocoding function to add markers to the map
}
/*
* This function loads a marker overlay on to the location provided
* and calls the addInfoWindow function to add an info window to it
* @param a location: google location object representing the location at which
* the marker is to be placed
* @param a windowText: String variable representing the information to be attached
* to the window.
*/
function loadMarker(location,windowText,address) {
var tempMarker = new google.maps.Marker({
position: location,
map: map,
address:address,
selected:"false"
});
google.maps.event.addListener(tempMarker, 'click',function(){
selectLocation(tempMarker);
});
google.maps.event.addListener(tempMarker, 'dblclick',function(){
deselectLocation(tempMarker);
});
addInfoWindow(windowText,tempMarker,tempMarker.address);
// add an information window anchored on the marker
tempMarker.setIcon('/imgs/workofficeMarker.png');
markersArray.push(tempMarker);
tempMarker.setMap(map);
// add the marker to the map at this location
}
/*
* A function to geocode the string type address passed into usable
* lat lng type co-ords
* @param address: a String representing the address to be geocoded
*/
function geocodeAddress (address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode( {'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
loadMarker(results[0].geometry.location,"Info here",address);
latlngArray.push(results[0].geometry.location);
} else {
alert("Geocode was not successful for the following reason: " +" "+ status);
}
});
}
/*
* This function adds an info window to each marker and allows it
* to be activated on click.
* @Param infoText: a String representing the data to be included in the
* info window
* @Param marker: a Google Marker Object to attach the Text Window to.
*/
function addInfoWindow (infoText,marker) {
var contentString = '<div id = "windowContent">'+
'<h4> Details</h4>'+'</div>'+
'<div id ="windowContent">'
+'</br>'
+infoText
+ '</br>'
+ '<p><label for="mapsUkSaddr">Your address</label> <form action="http://maps.google.co.uk/maps" method="get" target="_blank">'
+ '<input type="text" name="saddr" id="mapsUkSaddr" value="" size="20"/>'
+ '<input type="submit" value="Get directions" />'
+'<input type="hidden" name="daddr" value=' + '\"'+ marker.address +'\"' + '/>'
+'<input type="hidden" name="hl" value="en" /> </p>'
+ '</form>'
+ '</div>';
var tempInfoWindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker,'rightclick', function() {
tempInfoWindow.open(map,marker);
});
}
/*
* A function to resize the bounds of the map to fit selected locations
*
*/
function getSelected () {
if (markersArray.length == 0) {
return -1;
}
else {
selectedMarkersAdds = new Array();
for (var i = 0; i < markersArrayAdds.length; i++) {
if ( markersArray[i].selected == "true") {
selectedMarkersAdds.push( markersArray[i].address)
}
}
return selectedMarkersAdds;
}
}
function sizeMap() {
var bounds = new google.maps.LatLngBounds();
for ( var i = 0; i < 1; i++) {
alert(latlngArray[i]);
var tempLatLng = new google.maps.LatLng(latlngArray[i]);
alert(tempLatLng);
bounds.extend(tempLatLng);
}
map.fitBounds(bounds);
}
/*
* This function allow a given location to be selected as a potential
* vist location. The location is added to the selected array to
* allow resizing and changes the icons colour to show selection
* @param a marker: Google maps Marker object representing the marker to be
* selected.
*/
function selectLocation (marker) {
var markerIndex = checkForMarker(marker);
if (markerIndex == -1) {
alert ("Marker specified in selection not found");
return;
}
else {
markersArray[markerIndex].selected = "true";
markersArray[markerIndex].setIcon('/imgs/workofficeRedMarker.png');
return;
}
}
/*
* Allows the specified marker to be deselected
* @param marker: a Google Maps marker object representing the marker
* to be deselected
*/
function deselectLocation (marker) {
var markerIndex = checkForMarker(marker);
if (markerIndex == -1) {
alert ("Marker specified in deselection not found");
return;
}
else {
markersArray[markerIndex].selected = "false";
markersArray[markerIndex].setIcon('/imgs/workofficeMarker.png');
return;
}
}
/*
* This function allows a route to be calculated to each location
* selected and displayed: Google maps LatLng object representing the start of the route
* @param a endLocation: Google maps LatLng object representing the end of the route
*/
function calculateRoot (startLocation,endLocation) {
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById("directions"));
var request = {
origin:startLocation,
destination:endLocation,
provideRouteAlternatives: true
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
}
/*
* This function shows the route from the chosen start location
* to all of the avaliable placement locations
*/
function showSpiderView(){
for (var i = 0; i<latlngArray.length; i++ ) {
calculateRoot(startLatLng,latlngArray[i]);
}
sizeMap();
}
/*
* This function allows the selectedLocations array to be checked
* to see if a fiven marker has already been selected
* @param marker: A Google maps marker type object to be searched for
* @return integer value of array postion if marker is found -1 otherwise
*/
function checkForMarker (marker) {
if (markersArray.length !=0){
for (var i = 0; i < markersArray.length; i++ ) {
if (marker.address == markersArray[i].address){
return i
}
}
}
else {
return -1;
}
}
/*
* Display only placement locations that have been selected by the
* user
*/
function showOnlySelected () {
clearMarkers();
if (markersArray.length != 0) {
for (var i = 0; i < markersArray.length; i ++ ) {
if (markersArray[i].selected == "true") {
markersArray[i].setMap(map);
}
}
}
else {
alert ("No locations are avaliable to show");
return;
}
}
/*
* A function to allow all placement locations to be displayed
*/
function showAll () {
clearMarkers();
if (markersArray != 0) {
for (var i = 0; i < markersArray.length; i ++) {
markersArray[i].setMap(map);
}
}
else {
alert ("No markers found to display")
return;
}
}
/*
* A function to allow all markers to be cleared from the screen
*/
function clearMarkers () {
if (markersArray.length != 0) {
for (var i = 0; i < markersArray.length; i ++) {
markersArray[i].setMap(null);
}
}
else {
alert ("No markers avaliable to clear");
}
}
// initilise all the page components by calling there load functions
function init () {
load_grid();
load_map();
}
昨晚似乎在工作,但在停止工作之前我必须改变一些东西。 (这将教会我不要在凌晨 2:00 疲倦地编码:-))各位好心人能指点一下吗?
按照要求,第 16 行内容如下:
J.toSpan=function(){return new P(this.$[Ta]()?0:this.$.d-this.$.b,ge(this.ba),i)};na(J,function(){return this.$[Ta]()||this.ba[Ta]()});function je(a,b){return function(c){if(!b)for(var d in c)a[d]||aa(ia("Unknown property <"+(d+">")));var e;for(d in a)try{var f=c[d];if(!a[d](f)){e="Invalid value for property <"+(d+(">: "+f));break}}catch(g){e="Error in property <"+(d+(">: ("+(g[dc]+")")));break}e&&aa(ia(e));return i}}function ke(a){return a==j}function le(a){try{return!!a.cloneNode}catch(b){return k}}function me(a,b){var c=Kd(b)?b:i;return function(b){return b==j&&c||b instanceof a}}
一直在尝试弄清楚它的含义,但无法充分理解它,认为它可能与 JSON 请求对象有关,但我不确定
最佳答案
您的请求
var request = {
origin:startLocation,
destination:endLocation,
provideRouteAlternatives: true
};
还应该指定travelMode,例如
travelMode: google.maps.DirectionsTravelMode.DRIVING
http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsRequest
关于javascript - 属性 <travelMode> 值无效 : undefined, 什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9573902/
我有一个接受以下参数的函数: int setvalue(void (*)(void *)); 为了满足参数:void (*)(void *),我创建了这样一个函数: static void *
我有以下代码: typedef void VOID; int f(void); int g(VOID); 在 C 中编译得很好(在 Fedora 10 上使用 gcc 4.3.2)。与 C++ 编译的
这个问题已经有答案了: Is f(void) deprecated in modern C and C++? [duplicate] (6 个回答) 已关闭 7 年前。 B.A.T.M.A.N./A.
我在 ASP.NET Core 3.1 项目上有以下 Identity Server 4 配置: services .AddIdentityServer(y => { y.Events.R
我们有一个 O365 租户,一切都是开箱即用的。租户放置在德国云中,而不是全局 (office.de) 中。我们还开发了一个 Office 插件,使用 OAuth 2.0 授权访问共享点。首先,我们向
我有一个如下所示的路由 routes.MapRoute( name: "Default", url: "{controller}/{action}/{i
我正在尝试使用 OAuth2.0 访问 google 文档。我已经从 Google API 控制台获取了客户端 ID 和 key 。但是当我运行这段代码时,我收到了异常。如果我遗漏了什么,有人可以建议
此代码有效: let mut b: Vec = Vec::with_capacity(a.len()); for val in a.iter() { b.push(val); } 此代码不起作
使用 client_credintials 授权类型请求 EWS oauth2 v2.0 的访问 token 时出现错误。 https://login.microsoftonline.com/tena
我通过 Java 应用程序使用 Google 电子表格时遇到了问题。我创建了应用程序,该应用程序运行了 1 年多,没有任何问题,我什至在 Create Spreadsheet using Google
如何创建 匹配所有无效 Base64 字符的正则表达式?我在堆栈上找到了 [^a-zA-Z0-9+/=\n\r].*$ 但是当我尝试时我得到了带有 - 符号的结果字符串.我根本不知道正则表达式,任何人
我从 Gitlab CI/CD Pipelines 获得错误信息:yaml invalid。问题是由 .gitlab-ci.yml 脚本的第五行引起的: - 'ssh deployer@gita
我有 3 个数据源,设置如下: @Configuration @Component public class DataSourceConfig { @Bean("foo") @Conf
你好,我想用bulkCreate ex 插入数据: [ { "typeId": 5, "devEui": "0094E796CBFCFEF9", "application_name": "Pressu
UIApplicationExitsOnSuspend 不会强制我的应用程序退出。我已经清理过目标、删除了应用程序、重建并重新安装了很多次。 我确实需要退出我的应用程序。 最佳答案 您是否链接了 SD
在 iPhone 配置门户上,显示我的 iPhone 团队配置配置文件无效。有一个“由 Xcode 管理”文本。 “续订”按钮被禁用。 我该如何解决这个问题?谢谢 最佳答案 使用 Xcode 3.2.
好的,所以今天我用我们的“实时”数据库中的新信息更新了我的数据库……从那时起,我的一个表格就出现了问题。如果您需要任何代码,请告诉我,我将对其进行编辑并发布所需的代码... 我有一个报告表格,其中有一
我有一个结构体,其中有一个元素表示为 void (*func)(); 我知道 void 指针通常用于函数指针,但我似乎无法定义该函数。我不断收到取消引用指向不完整类型的指针。我用谷歌搜索了一下但没有结
我正在尝试使用 Coldfusion 9 从 ning 网络获取凭证,所以首先这是测试 api 的 curl 语法: curl -k https://external.ningapis.com/xn/
这个问题已经有答案了: Does C have references? (2 个回答) 已关闭 4 年前。 我正在学习 C 语言引用,这是我的代码: #include int main(void)
我是一名优秀的程序员,十分优秀!