【发布时间】:2015-03-26 11:41:59
【问题描述】:
无法理解 Google Map 和 Google Places API 之间的区别。
刚刚实现了简单的谷歌地图代码
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
var mapProp = {
center:new google.maps.LatLng(25.0000, 66.0000),
zoom:4,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<select name="home_city_select" id="home_city_select" data-icon="carat-d" style="width:auto;" onchange="getCity()">
<option>
....
</option>
</select>
<div data-role="content" style="padding: 0px" dir="ltr">
<div id="googleMap" style="width:100%;height:215px;"></div>
</div>
</body>
JS
//City--tested by multiple code ways
function getCity() {
var x = document.getElementById("home_city_select").value;
var xx=$("#home_city_select").val();
//alert(xx);
}
$(function() {
$("#home_city_select").change(function() {
alert( $('option:selected', this).text() );
});
});
这里我必须手动给出经纬度。但这不是正确的方法。没有人知道每个城市的经纬度。
- 但是如何编写javascript以便在选择城市名称时,例如 地图下拉菜单中的“孟买”发生变化,并在地图上显示餐厅符号。
- 如何在列表中获取餐厅名称,在 所选城市。
- 按食品名称搜索。
最终实现上述所需功能需要哪些正确代码?请提供代码。
【问题讨论】:
标签: javascript html google-maps