-1
我只是想在谷歌地图上添加标记API在谷歌地图上添加标记
我想创建自定义标记和半径圆。我已经使用 谷歌地图地理编码服务。基本上我想在选定的城市中显示推文,并在某些半径和个人资料图片中作为标记和信息框。
<!DOCTYPE html>
<html>
<head>
<title>Geocoding service</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
#floating-panel {
position: absolute;
top: 10px;
left: 25%;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
text-align: center;
font-family: 'Roboto','sans-serif';
line-height: 30px;
padding-left: 10px;
}
</style>
</head>
<body>
<div id="floating-panel">
<input id="address" type="textbox" placeholder="Bangkok">
<input id="submit" type="button" value="Search">
</div>
<div id="map"></div>
<script>
function initMap() {
var place= {lat: 13.7565, lng: 100.5018};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 8,
center: place
});
var geocoder = new google.maps.Geocoder();
document.getElementById('submit').addEventListener('click', function() {
geocodeAddress(geocoder, map);
});
}
function geocodeAddress(geocoder, resultsMap) {
var address = document.getElementById('address').value;
geocoder.geocode({'address': address}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
resultsMap.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: resultsMap,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
// Create marker
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(13.7563, 100.5018),
title: 'Some location'
});
var circle = new google.maps.Circle({
map: map,
radius: 16093, // 10 miles in metres
fillColor: '#AA0000'
});
circle.bindTo('center', marker, 'position');
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDPgJahvyB7ZJb8bm-X0Z5KuCp5vtSSx6A&callback=initMap">
</script>
</body>
</html>
能描述一下你的问题吗?请阅读:http://stackoverflow.com/help/how-to-ask –
我只是想添加标记在谷歌地图API – Shurya
这不是你的问题的描述,我们没有代码交付服务... –