Javascript JS和Google地图-以标记为中心的地图
我无法用记号笔将地图居中,这是b*:Javascript JS和Google地图-以标记为中心的地图,javascript,google-maps,google-maps-embed,Javascript,Google Maps,Google Maps Embed,我无法用记号笔将地图居中,这是b*: <iframe width="555" height="450" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?key=***&q=<? echo urlencode($address); ?>&zoom=14
<iframe
width="555"
height="450"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=***&q=<? echo urlencode($address); ?>&zoom=14">
</iframe>
不幸的是,我无法使它与iframe一起工作,而是使用了JS方式 JS: HTMl:
当页面加载时,我避免使用cause导致CSS显示为null的另一个问题。。。但这一问题得到了解决(没有理由解释原因如何不涉及问题)
无论如何,如果有人找到iframe示例的解决方案,仍然会很有趣…但这就是所有人o/如果你有纬度和经度,你可以指定
中心URL属性。但是,请看,我希望放置
模式会自动将地图居中于你的地址上,只是我没有lat这是一个动态页面,位置会随着页面管理员给出的地址而改变
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(40.730885,-73.997383);
var mapOptions = {
scrollwheel: true,
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map"), mapOptions );
var address = 'address string';
geocoder.geocode(
{ 'address': address},
function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
marker = new google.maps.Marker({
draggable: true,
map: map,
position: results[0].geometry.location
});
} else {
//alert('Location not found.');
}
}
);
<div id="map-canvas">
<div id="map" style="width:555px;height:450px;"></div>
</div>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=true"></script>