如何启用谷歌地图控制器(对,对.等箭)
How to enable Google map controllers (right,right..etc arrows)
我已经建立了一个应用程序来搜索我的位置。
代码
var map;
var gdir;
var geocoder = null;
var addressMarker;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById("directions"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
map.setCenter(new GLatLng(51.519853,-0.122566), 14)
var point = new GLatLng(51.519853,-0.122566); //CHANGE THESE COORDINATES
map.addOverlay(new GMarker(point));
map.openInfoWindow(map.getCenter(),html)
}
}
function setDirections(fromAddress) {
gdir.load("from: " + fromAddress + " to: 51.519741,-0.122596 ");
}
function handleErrors(){
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) {
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.'nError code: " + gdir.getStatus().code);
} else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) {
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.'n Error code: " + gdir.getStatus().code);
} else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) {
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.'n Error code: " + gdir.getStatus().code);
} else if (gdir.getStatus().code == G_GEO_BAD_KEY) {
alert("The given key is either invalid or does not match the domain for which it was given. 'n Error code: " + gdir.getStatus().code);
} else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) {
alert("A directions request could not be successfully parsed.'n Error code: " + gdir.getStatus().code);
} else {
alert("An unknown error occurred.");
}
}
function onGDirectionsLoad(){}
它工作正常。但是没有导航键。谁能告诉我怎么激活它呢
如果你想在屏幕上放置不同的平移控件(例如,在谷歌地图上常见的四个方向图标),你可能想看看这个版本2的谷歌地图Javascript API控件教程。
基本上,该链接描述了在什么情况下哪些控件会自动出现。但是,如果您想强制控件进入您的google地图,您可以这样做:
function initialize() {
//assuming 'map' already exists...
//add a large pan / zoom control to the map
map.addControl(new GLargeMapControl());
}
相关文章:
- 如何在读取XLS/XLSX本地文件时,使用IE的javascript代码启用未标记为安全的ActiveX控件
- 如何使用jquery强制一个单词更改大小写等以保留品牌
- 如何在 API 调用后和 if 语句中启用提交按钮
- 语义ui如何使用javascript启用或禁用下拉列表
- 使用正则表达式将输入格式设置为单字符逗号、单字符逗号等
- IE6在启用/禁用文本字段上闪烁
- 传单中如何在更改基层时启用/禁用覆盖层
- 根据字段的值启用按钮
- 如何使用javascript函数在gridview中按行启用/禁用复选框
- 如何禁用和启用css规则
- 淘汰赛.JS'启用'长度绑定条件不起作用
- 如何动态检测Mozilla/Chrome上是否启用SSO
- 捕获所有常见类型的重定向、头、元、JavaScript等
- 如何使用element.myobj.prop等具有对象属性的元素
- 如何重新启用禁用的谷歌地图v3拖放、缩放等
- 重新启用文本选择(Opera、webkit等)
- 如何在 Yii2 所见即所得的编校器中启用完整的 html 支持(html,head,body、meta 标记等)
- 如何在客户端(浏览器/CLI等)启用Javascript文件(如jQuery)和CSS文件的缓存
- 如何启用谷歌地图控制器(对,对.等箭)
- 如何启用akamai缓存图像,css, js等