Gmaps4Rails - 创建折线
我对这个美妙的 gem gmaps4rails 有疑问。 是否可以在地图上打印一条折线,该折线的点之间没有不在标记列表中的位置?
为了更清楚起见,我添加了这段代码,取自 Rails 创建的 HTML 页面:
<script type="text/javascript" charset="utf-8">
function gmaps4rails_init() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/src/infobox.js";
document.body.appendChild(script);
Gmaps4Rails.map_options.type = 'TERRAIN';
Gmaps4Rails.map_options.auto_adjust = true;
Gmaps4Rails.initialize();
Gmaps4Rails.markers = [
{"latitude": "41.97", "longitude": "12.67", "description": "DEPARTURE DESCRIPTION HERE", "title": "TITLE HERE"},
{"latitude": "45.58", "longitude": "12.57", "description": "ARRIVE DESCRIPTION HERE", "title": "TITLE HERE"}
];
Gmaps4Rails.create_markers();
Gmaps4Rails.polylines = [
[
{"latitude": "41.97", "longitude": "12.67"},
{"latitude": "42.78", "longitude": "12.6"},
{"latitude": "45.58", "longitude": "12.57"}
]
];
Gmaps4Rails.polylines_conf.strokeColor = '#444444';
Gmaps4Rails.create_polylines();
if(typeof gmaps4rails_callback == 'function') { gmaps4rails_callback(); }
}
window.onload = gmaps4rails_init;
</script>
在地图上,我只想将起点 (41.97, 12.67) 和终点 (45.58, 12.57) 显示为标记。 但我还想创建一条从起点到终点的折线:该折线必须从另一个中间点(42.78,12.6)经过。
问题是地图上显示的折线是错误的:该线从第一个点到第三个点,但没有经过第二个点。
所以,我的问题是:我是否必须将折线的所有点包含为标记?
编辑:从此页面 https://github.com/apneadiving/ Google-Maps-for-Rails/wiki/Display-Everything!似乎很明显,即使它的点不在标记列表中,您也可以显示折线。 那么,为什么我的折线显示不正确?
I have an issue with this wonderful gem gmaps4rails.
Is it possible to print on the map a polyline that doesn't have between its points a location that it's not in the markers list?
To be more clear, I add this code, taken from the HTML page created by Rails:
<script type="text/javascript" charset="utf-8">
function gmaps4rails_init() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/src/infobox.js";
document.body.appendChild(script);
Gmaps4Rails.map_options.type = 'TERRAIN';
Gmaps4Rails.map_options.auto_adjust = true;
Gmaps4Rails.initialize();
Gmaps4Rails.markers = [
{"latitude": "41.97", "longitude": "12.67", "description": "DEPARTURE DESCRIPTION HERE", "title": "TITLE HERE"},
{"latitude": "45.58", "longitude": "12.57", "description": "ARRIVE DESCRIPTION HERE", "title": "TITLE HERE"}
];
Gmaps4Rails.create_markers();
Gmaps4Rails.polylines = [
[
{"latitude": "41.97", "longitude": "12.67"},
{"latitude": "42.78", "longitude": "12.6"},
{"latitude": "45.58", "longitude": "12.57"}
]
];
Gmaps4Rails.polylines_conf.strokeColor = '#444444';
Gmaps4Rails.create_polylines();
if(typeof gmaps4rails_callback == 'function') { gmaps4rails_callback(); }
}
window.onload = gmaps4rails_init;
</script>
On the map I want only the start point (41.97, 12.67) end the end point (45.58, 12.57) displayed as markers.
But I also want to create a polyline from the start pont to the end point: this polyline has to pass from another intermediate point (42.78, 12.6).
The problem is that the displayed polyline on the map is wrong: the line goes from the first point to the third pont without passing through the second one.
So, my question is: do I have to include as markers all the points of the polyline?
EDIT: from this page https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Display-Everything! it seems clear that you can display a polyline even if its points are not in the markers list.
So, why my polyline is not displayed correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论