- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 google map 和 API 的新手,试图通过点击将 map 平移到某个区域。我没有时间在 API 引用中找到我需要的东西,也不确定如何去做,所以我没有太多东西,但这是我目前所拥有的。
我想让它点击任何区域都会平移并放大以显示该区域的大部分,我相信这就是 panToBounds是为了做。
大部分功能将来自点击文本名称并让 map 加载显示正确的位置,而不是点击 map 本身
function initialize_neighbourhoodmap(neighbourhood_name) {
var latlng = new google.maps.LatLng(42.949442,-81.228125);
var zoom = 11;
var neighbourhood_center = get_neighbourhood_center();
var myOptions = {
zoom: zoom,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("neighbourhood_map"),
myOptions);
var neighbourhoods = new google.maps.KmlLayer('http://maps.google.com/maps/ms?authuser=0&ie=UTF8&hl=en&oe=UTF8&vps=3&msa=0&output=kml&msid=217366496682144933685.0004bf3be50d3cd7ad1c2', {suppressInfoWindows: true, preserveViewport:true});
neighbourhoods.setMap(map);
google.maps.event.addListener(neighbourhoods, 'click', function(KmlFeatureData) {
var neighbourhood_name = KmlFeatureData.featureData.name;
load_neighbourhood(neighbourhood_name, neighbourhoods);
window.location = "#neighbourhood-neighbourhood "+neighbourhood_name;
});
if(typeof neighbourhood_name !== 'undefined'){
load_neighbourhood(neighbourhood_name, neighbourhood_center);
}
}
function load_neighbourhood (neighbourhood_name, neighbourhoods) {
var neighbourhoodbounds = nonexistentgetboundsfunction(neighbourhood_name);
map.panToBounds(neighbourhood_center[neighbourhood_name][0]);
$('#neighbourhood h2').html('neighbourhood '+neighbourhood_name);
}
最佳答案
您确定需要其他功能吗?在我看来,用户界面变得很尴尬。嗯,这里是:http://jsfiddle.net/g343k/3/
我遇到了一个奇怪的“错误”,或者有些人可能称之为“特征”,它与 KML 多边形相关联。单击某个区域时, map 会平移到该区域的中心;但是,当单击外部 planning_district 区域时, map 会平移到框的中心,而不是单击所在的位置(Sean Mickey 在 FireFox 12 中进行了测试,它平移到单击)。除了将规划区分割为几十个更小的盒子之外,我想不出解决这个问题的办法:(现在我已经编写了代码来忽略对规划区的点击。
google.maps.event.addListener(neighbourhoods, 'click', function(KmlFeatureData) {
var neighbourhood_name = KmlFeatureData.featureData.name;
load_neighbourhood(neighbourhood_name, neighbourhoods);
window.location = "#neighbourhood-neighbourhood "+neighbourhood_name;
// ADDED
// Consider what to do when this outer area is clicked
if(KmlFeatureData.featureData.name!="planning_districts_2008") {
map.panTo(KmlFeatureData.latLng);
}
});
// LEFT OUT
//if(typeof neighbourhood_name !== 'undefined'){
// load_neighbourhood(neighbourhood_name, neighbourhood_center);
//}
// ADDED
google.maps.event.addListener(map, 'click', function(event) {
map.panTo(event.latLng);
});
关于javascript - kml 文件中来自多边形的 LatLngBounds?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10456290/
我试图将变量传递给 google.maps.LatLngBounds,但它不起作用。似乎唯一有效的是,如果我将数字硬编码为 float (文字),如果我尝试下面的内容,它会失败。我已经尝试了各种转换方
我想获取 Google map 框架右上角和左下角的 LatLng 以创建 LatLngBounds。有可能吗? 最佳答案 这可以使用 Map View API 轻松确定: yourMapFragme
我想将相机移动到适合 LatLngBounds 标记高度的位置。到目前为止,我可以使用以下代码来匹配标记的 anchor : LatLngBounds.Builder builder = new La
我在我的 android 应用程序中实现了 Google map v2 api。在这里,在一项 Activity 中,我成功地初始化了谷歌地图对象。我成功地在 map 中添加了五个标记,并且当前位置也
我是 google map 和 API 的新手,试图通过点击将 map 平移到某个区域。我没有时间在 API 引用中找到我需要的东西,也不确定如何去做,所以我没有太多东西,但这是我目前所拥有的。 我想
我有一个对应于矩形的字符串,如下所示: ((x1,y1),x2,y2)) 我想将其转换为 LatLngBounds 对象,并通过以下方式绘制矩形: myRectangle.setBounds(latL
在方法中 CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds, int width, int height, int padding);
我想显示位于印度和美国的所有标记。这次 LatLngBounds 将显示缩放级别为 0,并且 map 可见区域介于印度和美国之间。有什么解决办法吗?对此的解决方案是,如果在 INDIA 中提供更多标记
我在我的应用程序中使用 PlacePicker。突然间它的行为很糟糕。当它启动时指向 (0.0, 0.0) lat lng。我不确定谷歌服务是否改变了什么。早些时候它工作正常,因为从 3 天开始它不工
我在我的 android 应用程序中使用 AutoComplete Places Widget。我只想将界限设置为印度。但我不知道印度的 LatLngBounds。有人知道坐标吗? 最佳答案 你可以用
我在搜索中没有找到答案,有一些关于 SO 的答案,但它们对我不起作用。 我在 map 上有 2 个标记,我正在使用 LatLngBounds 构建器,以便让相机缩放到正确的缩放级别以将它们都包含在内。
我想在 X 米处围绕中心点 (LatLng) 创建一个正方形 (LatLngBounds)。 最佳答案 使用 L.LatLng.toBounds() method ,例如 var center = L
好吧,在阅读了 Antonio 的评论后,我在我的代码中接受了这个。现在,无论我提交的百分比是多少,它仍然认为我的对象在边界框之外。 My Position 是传入的marker。 LatLngBou
我正在尝试使用 react-google-maps 渲染 Google map 。在 map 完全加载之前,我使用 geolocation.navigator 函数获取用户当前位置,但我需要使用用户位
这是我的代码: LatLngBounds.Builder builder = new LatLngBounds.Builder(); for(int x = firstVisibleItem; x
是否有一个函数允许为 MapFragment 的不同边缘指定默认填充值,即类似于 CameraUpdateFactory.newLatLngBounds(LatLngBounds 边界,整数填充) 它
我正在尝试在 map 上放置一些标记。数据是从数据库检索并使用 JSON 循环读取的。 标记已放置,但我也尝试在 map 上显示所有标记并将 View 居中。这似乎是随机的,我刷新页面,有时它显示 3
我通过调用获取谷歌地图的当前边界: map.getBounds() 这将返回 LatLngBounds。例如: ((-26.574013562724005, -1.5375947819336488),
我正在使用 google map javascript API,目前我正在尝试创建一个 LatLngBounds 对象,以便我可以根据数组中的位置将其应用到我的 google map 。 我正在找到西
Google Places Autocomplete API 中使用的 LatLngBounds 对象是什么? .. 和/或它是什么意思: biasing the results to a speci
我是一名优秀的程序员,十分优秀!