- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个谷歌地图,我必须将数据库中的数据显示到谷歌地图中。我已经做到了这一点,我正在从 mysql 数据库中提取数据到谷歌地图中。所有城市都从数据库中填充,现在我必须绘制我从数据库填充的城市之间的一条线。这是我到目前为止所做的代码..
<script type="text/javascript">
/*This is */
function getCallbackFunction(req, processData) {
// Return an anonymous function that listens to the
// XMLHttpRequest instance
return function () {
// If the request's status is "complete"
if (req.readyState == 4) {
if (req.status == 200) {
// Pass the XML payload of the response to the
// handler function
processData(req.responseXML);
} else {
// An HTTP problem has occurred
alert("HTTP error: "+req.status);
}
}
}
}
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var gmarkers = [];
function getMarker(id) {
for (var i = 0; i <= gmarkers.length; i++) {
var marker = gmarkers[i];
if (marker.id == id) {
return marker;
}
}
return null;
}
function load() {
if (GBrowserIsCompatible()) {
var i = 0;
var baseIcon = new GIcon();
baseIcon.iconSize=new GSize(12,12);
baseIcon.shadowSize=new GSize(12,12);
baseIcon.iconAnchor=new GPoint(6,6);
baseIcon.infoWindowAnchor=new GPoint(6,6);
var pinIcon = new GIcon(baseIcon, "http://maps.google.co.uk/intl/en_ALL/mapfiles/ms/micons/red-dot.png", null, null);
// A function to create the marker and set up the event window
function createLibraryMarker(point,name,id) {
var baseIcon = new GIcon();
baseIcon.iconSize=new GSize(20,12);
baseIcon.shadowSize=new GSize(20,12);
baseIcon.iconAnchor=new GPoint(10,6);
baseIcon.infoWindowAnchor=new GPoint(10,0);
var icon = new GIcon(baseIcon, "images/smaller-library-icon.gif", null, null);
var marker = new GMarker(point,icon);
// === store the name so that the tooltip function can use it ===
marker.tooltip = '<div class="tooltip">'+name+'</div>';
marker.id = id;
GEvent.addListener(marker, "click", function() {
openInfoWindow(marker,"" + id);
});
gmarkers[i] = marker;
i++;
map.addOverlay(marker);
// ====== The new marker "mouseover" and "mouseout" listeners ======
GEvent.addListener(marker,"mouseover", function() {
showTooltip(marker);
});
GEvent.addListener(marker,"mouseout", function() {
tooltip.style.visibility="hidden"
});
}
//
// The list of city markers, loaded only once
//
var cityMarkers = null;
function displayCities() {
if (cityMarkers == null) {
loadCities();
} else {
displayCityMarkers();
}
}
function loadCities() {
// Read the data from data.xml
var request = GXmlHttp.create();
request.open("GET", "/maps/LibraryDirectory?method=findAllCities", true);
request.onreadystatechange = getCallbackFunction(request, processCityData);
request.send(null);
}
/**
* Process the city list in XML form, store it in cityMarkers,
* and display the markers.
*/
function processCityData(xmlDoc) {
cityMarkers = xmlDoc.documentElement.getElementsByTagName("marker");
displayCityMarkers();
}
function displayCityMarkers() {
map.clearOverlays();
for (var i = 0; i < cityMarkers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(cityMarkers[i].getElementsByTagName("latitude")[0].firstChild.nodeValue);
var lng = parseFloat(cityMarkers[i].getElementsByTagName("longitude")[0].firstChild.nodeValue);
var id = cityMarkers[i].getElementsByTagName("id")[0].firstChild.nodeValue;
var label = cityMarkers[i].getElementsByTagName("name")[0].firstChild.nodeValue;
// create the marker
createCityMarker(new GLatLng(lat,lng),label,id);
}
}
function createCityMarker(point,name,id) {
var marker = new GMarker(point,pinIcon);
// === store the name so that the tooltip function can use it ===
marker.tooltip = '<div class="tooltip">'+name+'</div>';
marker.id = id;
marker.point = point;
GEvent.addListener(marker, "click", function(point) {
map.setCenter(new GLatLng(marker.point.y,marker.point.x),10);
});
gmarkers[i] = marker;
i++;
map.addOverlay(marker);
// ====== The new marker "mouseover" and "mouseout" listeners ======
GEvent.addListener(marker,"mouseover", function() {
showTooltip(marker);
});
GEvent.addListener(marker,"mouseout", function() {
tooltip.style.visibility="hidden"
});
}
// ====== This function displays the tooltip ======
function showTooltip(marker) {
tooltip.innerHTML = marker.tooltip;
var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());
var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
var anchor=marker.getIcon().iconAnchor;
var width=marker.getIcon().iconSize.width;
var height=tooltip.clientHeight;
var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - point.x - anchor.x + width, offset.y - point.y -anchor.y -height));
pos.apply(tooltip);
tooltip.style.visibility="visible";
}
// ===== This function is invoked when the mouse leaves an entry in the sidebar =====
// It hides the tooltip
function mymouseout() {
tooltip.style.visibility="hidden";
}
var myTrip = {
center:x,
zoom:4,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
// create the map
var map = new google.maps.Map(document.getElementById("map"),myTrip);
map.addControl(new GLargeMapControl());
map.addControl(new GOverviewMapControl());
map.enableDoubleClickZoom();
map.setCenter(new GLatLng(28.6100, 77.2300), 5);
// ====== set up marker mouseover tooltip div ======
var tooltip = document.createElement("div");
map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
tooltip.style.visibility="hidden";
displayCities();
GEvent.addListener(map, "zoomend", function(oldZoom, newZoom) {
if ((oldZoom <= 8) && (newZoom > 8)) {
//
// Switch to city markers
//
displayLibraries();
} else if ((oldZoom > 8) && (newZoom <= 8)) {
//
// Switch to library markers
//
displayCities();
}
});
}
else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 900px; height: 500px"></div>
var lat,var lng 这是来自数据库的纬度和经度。我必须使用这个经度和纬度来画线,请有人帮忙
最佳答案
一般答案是处理 cityMarkers 数组,根据其位置创建 google.maps.LatLng 对象的数组。使用该数组创建多段线。
该答案适用于 v2 或 v3;详细信息将取决于您最终使用哪个 API(但如 v2 is deprecated and scheduled to be turned off/transitioned to a wrapped v3 version that might not work for you ,您最好在 v3 中编写任何新代码)。
关于javascript - 如何在谷歌地图中的标记之间画一条线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19289720/
这两个包看起来非常相似: http://www.passportjs.org/packages/passport-google-oauth2/ http://www.passportjs.org/pa
我想在我的网站上添加通过 Google 和 Twitter 登录的按钮。我需要只使用应用程序的客户端而不是服务器端来完成此操作。但我没有找到任何 API。对于我发现的所有内容,我需要使用带有 key
我使用此链接通过 google plus 共享我的页面。 https://plus.google.com/share?url=http%3A%2F%2Fexample.com%2Fcompany%2
我正在尝试学习 google API,并且我的经验是使用 Python,因此我尝试使用 google api python 客户端来访问一些 google 服务,但在构建服务对象时遇到错误。 从 ap
在其实际的实时托管平台上构建实时站点的努力中,有没有办法告诉谷歌不要索引该网站?我发现了以下内容: http://support.google.com/webmasters/bin/answer.py
我正在开发一个 iOS 应用程序。当我运行用于 google+ 登录的程序时,在我点击允许访问按钮后,会显示此消息。 You've reached this page because we have
我有一个非常复杂的网站,每个页面包含 11 个 js 文件。 我最近添加了 google +1 按钮,代码如下: 这会正确显示 +1 按钮,直到我单击它。当我单击它时,出现此错误:https://
我正在尝试使用 google API 创建一个 html 文件,以便在 google MAPS 上显示 KML 文件。 这是 HTML 代码: function initMap() {
我是使用 Google Benchmark 的新手,在本地运行代码与在 Quick-Bench.com 上运行代码时,我收到了运行相同基准测试(下方)的不同结果,该基准测试使用 C++ 检索本地时间.
我已按照 Google 网站上的说明通过添加以下元标记在我的 AngularJS 网站上启用 Ajax 抓取: 呈现的内容有一些链接,如: User 1 User 2 User 3 还有一些呈现动态
通过 Google 手册实现 Google AppInvite - link . 启动 Invite Activity 并在 LogCat 中获取下一步: E/AppInviteAgent: Get
那么有人用过 Google 的 Go 吗?我想知道数学性能(例如触发器)与其他具有垃圾收集器的语言(如 Java 或 .NET)相比如何? 有人调查过吗? 最佳答案 理论性能:纯 Go 程序的理论性能
Stackdriver 测试我的网站启动速度慢 我们使用 cloudflare 作为我们的站点 CDN 提供商。我们使用 stackdriver 从外部测试站点可用性,我们将时间检查间隔设置为 1 分
我正在尝试使用 stax.GeneralConv() ( https://jax.readthedocs.io/en/latest/_modules/jax/experimental/stax.htm
我有一个从谷歌金融中提取日内数据的软件。但是,由于昨天 Google 更新了 API,所以软件报错了 Conversion from string HTML HEAD meta http-equiv=
我们在尝试从 Google 获取 oAuth token 时遇到“redirect_uri_mismatch”错误: [client 127.0.0.1:49892] {\n "error" : "
我的网站正在使用 Google reCAPTCHA 控件,但我听说它被阻止了 中国,反正我看到有人报告说将 API 更改为 https://www.recaptcha.net在中国工作? Anyone
背景 WordPress Google Adsense 谷歌自动插入 anchor 定广告 https://pptmon.com 问题 如下图所示,主播广告的容器高度太大了! 如何调整高度? 这是谷歌
我在使用 Google Colab 时遇到问题。当我想制作一个新的 Python3 Notebook 时,由于我登录了我的 Google 帐户,因此无法加载刚刚打开的新页面。 我该怎么办? 感谢您的帮
我正在使用 facebook和 google oauth2使用 passport js 登录, 有了这个流 用户点击登录按钮 重定向到 facebook/google auth 页面(取决于用户选择的
我是一名优秀的程序员,十分优秀!