使用谷歌地图jQuery更改半径中心图标

时间:2018-07-11 10:13:35

标签: jquery

以下是我针对带有多个标记的Google地图的代码。在这种情况下,我不能将图像提供给半径中心图标。 image of center icon 如何越过半径的中心圆作为图像。我无法更改中心圆的图像。我发现在Google中搜索所有文档,但我无法为此找到解决方案。请任何人为我的问题提供宝贵的答案。

var latlong = {lat: <?php echo $centerlat; ?>, lng: <?php echo $centerlon; ?>};
var map = new google.maps.Map(document.getElementById('map'), {
  zoom: <?php echo (int)$map_zoom; ?>,
  center:  latlong,
  mapTypeId: google.maps.MapTypeId.TERRAIN
});
for (var city in citymap) {
  // Add the circle for this city to the map.
  var cityCircle = new google.maps.Circle({
    strokeColor: 'blue',
    strokeOpacity: 0.8,
    strokeWeight: 1,
    fillColor: 'transparent',
    fillOpacity: 0,
    map: map,
    center: citymap[city].center,
    radius: <?php echo ($global_config["MapRadius"]*1000); ?>,
    editable:true
  });
  cityCircle.name = city;
  var radius = cityCircle.radius;

  google.maps.event.addListener(cityCircle, 'radius_changed', function()
  {
    var radius = cityCircle.radius;
    jQuery("#radius_frm").val(radius);
    var dataString = 'action='+"radius_search"+'&radius='+radius+'&frm_location=<?php echo $data['frm_location']; ?>';      
    $.ajax({
      type: "POST",
      url: GlobalPath+"ajax/ajax_file.php",
      data: dataString,
      cache: false,
      success: function(response) {
        jQuery("#map").html(response);          
      } 
    });
  });      
  google.maps.event.addListener(map, 'zoom_changed', function()
  {
    zoomLevel = map.getZoom();
    jQuery("#frm_level_z").val(zoomLevel);                
  });
}    
var latlong = {lat: <?php echo $centerlat; ?>, lng: <?php echo $centerlon; ?>};
var points = [
<?php
    if (!empty($uniqueResult)) {
      foreach ( $uniqueResult as $key => $location ) {
        if ($location['latitude'] != '' && $location['longitude']) { 
          $map_lat      = $location['latitude'];
          $map_lng      = $location['longitude']; 
          $postal_code  = $location['postal_code']; 
          $type         = $location['ImageName'];
        }
    ?>
{postal_code: <?php echo $postal_code; ?>, lat: <?php echo $map_lat;?>, lng: <?php echo $map_lng;?>, type: '<?php echo $type."@@@".$postal_code; ?>'},
<?php } }  ?>
];
//console.log("postal", points);    
for (var i = 0; i < points.length; i++) { 
  var point = points[i];
  var current_type = point.type;
  new_type =  current_type.split('@@@');      
  image_icon =  'images/map/'+new_type[0]+'.svg';

  var marker = new google.maps.Marker({
    id: {postal_code: point.postal},
    map: map,
    position: {lat: point.lat, lng: point.lng},
    title: new_type[0]+'###'+new_type[1]+'###'+point.lat+'###'+point.lng,
    icon: image_icon,
  });
  google.maps.event.addListener(marker, 'click', (function(marker, i, position,id) {
    return function() {        
      var splite_title = marker.getTitle().split('###');         
      var type    = splite_title[0];         
      var zipcode = splite_title[1];
      var lat = splite_title[2];
      var lng = splite_title[3];          
      get_location_listings(lat, lng, type, zipcode, radius);          
    }
    })(marker, i));
}

}

0 个答案:

没有答案
相关问题