gup*_*ron 6 html embed google-maps
假设我有2个办公地点,我想用于我的联系页面.我希望有一个嵌入式谷歌地图,显示这两个位置.在谷歌地图本身,我可以显示两个地图标记.但是,嵌入的HTML代码仅使用输入的第一个地址.
问题1:是否可以更改Google提供的HTML嵌入代码以显示第二个位置的地图标记?
问题2(仅当上述答案为"是"时):如何?
以下是Google提供的一些示例嵌入代码:
<iframe width="920" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.ca/maps?hl=en&client=safari&q=33+Victoria+St.,+Toronto,+ON+M5C+3A1&ie=UTF8&hq=&hnear=33+Victoria+St,+Toronto,+Ontario+M5C+3A1&gl=ca&t=m&ll=43.536603,-79.796448&spn=0.696882,2.526855&z=9&iwloc=A&output=embed"></iframe><br /><small><a href="https://maps.google.ca/maps?hl=en&client=safari&q=33+Victoria+St.,+Toronto,+ON+M5C+3A1&ie=UTF8&hq=&hnear=33+Victoria+St,+Toronto,+Ontario+M5C+3A1&gl=ca&t=m&ll=43.536603,-79.796448&spn=0.696882,2.526855&z=9&iwloc=A&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>
Run Code Online (Sandbox Code Playgroud)
Suv*_*jah 11
您可以通过使用来实现另一种方式My Places.以下是实现此目的的步骤:
My Places旁边的按钮Get Directions- 单击该按钮.Create a Map左侧面板中的Save to map左侧面板结果列表底部的,并指定要将其保存到的地图(应该是您之前设置的标题).我不确定您的问题的答案,但Google API非常方便且相对容易学习.
创建标记实际上只需要3行,新标记,标记位置和您正在使用的地图.在JS中,创建具有多个标记的地图也相对较短.这是一个例子.
function initialize() {
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(-25.363882, 131.044922),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
var marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
});
var marker2 = new google.maps.Marker({
position: new google.maps.LatLng(35, 96),
map: map,
});
}
google.maps.event.addDomListener(window, 'load', initialize);
Run Code Online (Sandbox Code Playgroud)
如果将来需要,使用API还可以让您进一步向地图添加更多功能.最终,您可能希望标记显示其位置,甚至可能获得指向其中一个标记的方向.Google已经编写了所有可供任何人使用的代码.
这是使用融合表API的一个更高级的示例,但除了标记之外,还有许多很酷的功能可以使用. https://developers.google.com/fusiontables/docs/samples/infowindow_driving_directions