0

我的代码如下。它现在正在工作,但如果我取消注释图标行(//图标:'http://108.163.162.202:8080/finex/img/map_marker.png'),则不会显示所有标记及其标题。Google Map现在显示标记是我添加自定义图标

我想在我的页面中添加我的自定义标记,并且我的代码不允许我。

请帮忙,谢谢提前

$(function() { 
 
    
 
    var locations = [ 
 
     ['Jersey City', 40.7178746, -74.0718356], 
 
     ['Bronx', 40.8504989, -73.84934,5 ], 
 
     ['Union City', 40.7667435, -74.0303289], 
 
     ['Queens', 40.651018, -73.871192], 
 
     ['Ridgefield', 40.8256436, -74.0153092] 
 
    ]; 
 

 
    var map = new google.maps.Map(document.getElementById('map'), { 
 
     zoom: 11, 
 
     center: new google.maps.LatLng(40.7590615, -73.969231), 
 
     mapTypeId: google.maps.MapTypeId.ROADMAP, 
 
\t scrollwheel: false, 
 
\t mapTypeControl: false, 
 
\t scaleControl: false, 
 
\t navigationControl: true, 
 
\t draggable: false, 
 
\t zoomControlOptions: { 
 
\t \t style: google.maps.ZoomControlStyle.LARGE 
 
\t \t }, 
 
\t 
 

 
    }); 
 

 
    var infowindow = new google.maps.InfoWindow(); 
 

 
    var marker, i; 
 

 
    for (i = 0; i < locations.length; i++) { 
 
     marker = new google.maps.Marker({ 
 
     position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
 
     map: map, 
 
\t \t title: locations[i][0], 
 
     //icon: 'http://108.163.162.202:8080/finex/img/map_marker.png', 
 
     }); 
 

 
     google.maps.event.addListener(marker, 'click', (function(marker, i) { 
 
     return function() { 
 
      infowindow.setContent(marker.title); 
 
      infowindow.open(map, marker); 
 
     } 
 
     })(marker, i)); 
 
\t 
 
\t 
 
    } 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> 
 

 

 
<div style="height:300px;width:500px;" id="map"></div>

+0

它[适用于我,如果我使用公开可用的图标](http://jsfiddle.net/geocodezip/r67aeuks/) – geocodezip

回答

1

的形象已经用有限的.htaccess访问。我必须输入用户名和密码。也许这是问题? ;) 另外,如果没有任何内容,您可以在图标语句后留下逗号。

2
I did this in my project 
<input type="hidden" value="http://108.163.162.202:8080" id="baseUrl" > 
var baseUrl=$('#baseUrl').val(); 
icon: new google.maps.MarkerImage( 
        baseUrl+'images/marker-new.png', 
        null, 
        null, 
        // new google.maps.Point(0,0), 
        null, 
        new google.maps.Size(36, 36) 
       ), 
相关问题