我将标记放在地图上有问题。我有模型位置,我保存坐标x和y。我从列表中读取列表中的所有坐标并在视图中发送该列表。比我试图去所有列表并将标记放在loc上。但它不起作用。这是我的代码。
@(places: java.util.List[models.Location])
@adminmain("Post Offices") {
<ol class="breadcrumb">
<li><a href="@routes.Application.adminPanel()">Admin Panel</a></li>
<li><a href="#">Maps</a></li>
<li class="active">Location</li>
</ol>
<h1>Maps</h1
<div class="templatemo-maps">
<div class="row">
<div class="col-md-12 col-sm-12 margin-bottom-30">
<div id="map" style="position: relative; height: 700px; width: auto"></div>
AND SCRIPT
<script type="text/javascript">
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 5,
center: new google.maps.LatLng(43.8331, 18.3039),
mapTypeId: google.maps.MapTypeId.ROADMAP});
var i;
for(i = 0; i<@places.size(); i++){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(@places.get(i).x,@places.get(i).y),
map: map
});
}
map.addListener('center_changed', function() {
// 3 seconds after the center of the map has changed, pan back to the marker
window.setTimeout(function() {
map.panTo(marker.getPosition());
}, 3000);});
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, 'resize', function() {
map.setCenter(marker.getPosition());
});