Google maps 移除谷歌Pin+;在Google地图中打断新的线标记文本

Google maps 移除谷歌Pin+;在Google地图中打断新的线标记文本,google-maps,google-maps-markers,Google Maps,Google Maps Markers,我想做的是: 取下红色的谷歌别针 将蓝色文本拆分为多行,就像信息窗口一样 我环顾四周,得到的一些答案是:在标题或内容中使用\n或。 我试过了,但都不管用。 唯一对我有效的是标签(但不知何故它无法识别\n或 我有一个简单的代码 Javascript // The following example creates a marker label in Gillete Stadium var latLng = new google.maps.LatLng(-19.4914

我想做的是:

  • 取下红色的谷歌别针
  • 将蓝色文本拆分为多行,就像信息窗口一样
  • 我环顾四周,得到的一些答案是:在标题或内容中使用\n或
    。 我试过了,但都不管用。 唯一对我有效的是标签(但不知何故它无法识别\n或

    我有一个简单的代码

    Javascript

          // The following example creates a marker label in Gillete Stadium 
            var latLng = new google.maps.LatLng(-19.4914,132.5510);
    
            var map = new google.maps.Map(document.getElementById('map'), {
              zoom: 6,
              center: latLng
            });
    
            var marker = new google.maps.Marker({
              map: map,
              draggable: true,
              animation: google.maps.Animation.DROP,
              position: latLng,
              //title: 'Line 1<br/>Line2\nLine3',   //doesnt work   
              //content: 'Line 1<br/>Line2\nLine3', //doesnt work
            label: {
              color: 'black',
              fontWeight: 'bold',
              fontSize: '32px',
              text: 'Line 1<br/>Line2\nLine3',
            },
          });  
    

    非常感谢您提供的任何帮助

    我不确定我是否理解-您可以在不使用任何标记的情况下打开信息窗口,所以这可能会有所帮助

    <html>
        <head>
            <meta charset='utf-8' />
            <title>Google Maps: Infowindow with no marker</title>
            <script async defer src="//maps.google.com/maps/api/js?key=<API-KEY>&callback=initMap&region=en-GB&language=en"></script>
            <script>
                var map;
    
    
                function initMap(){
                    var infoWindow = new google.maps.InfoWindow({
                        maxWidth:100
                    });
                    var centre=new google.maps.LatLng( 55.959553, -3.178480 );
    
    
                    map = new google.maps.Map( document.getElementById('map'), {
                        zoom: 15,
                        center: centre,
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        disableDefaultUI: true
                    } );
    
    
                    infoWindow.setContent( "an infoWindow, centred on Edinburgh for no apparent reason, with no markers anywhere to be seen." );
                    infoWindow.setPosition( centre );
                    infoWindow.open( map, null );
                }
            </script>
    
            <style>
                body{ background:white;padding:0;margin:0; }
    
                #map {
                    width: 100%;
                    height:100%;
                    max-height: 100%;
                    clear:none;
                    display:block;
                    background:white;
                }
            </style>
        </head>
        <body>
            <div id='map'></div>
        </body>
    </html>
    
    
    谷歌地图:没有标记的信息窗口
    var映射;
    函数initMap(){
    var infoWindow=new google.maps.infoWindow({
    最大宽度:100
    });
    var center=new google.maps.LatLng(55.959553,-3.178480);
    map=new google.maps.map(document.getElementById('map'){
    缩放:15,
    中心:中心,,
    mapTypeId:google.maps.mapTypeId.ROADMAP,
    disableDefaultUI:true
    } );
    setContent(“一个信息窗口,无缘无故地以爱丁堡为中心,任何地方都看不到标记物。”);
    信息窗口。设置位置(中心);
    infoWindow.open(映射,空);
    }
    正文{背景:白色;填充:0;边距:0;}
    #地图{
    宽度:100%;
    身高:100%;
    最大高度:100%;
    明确:无;
    显示:块;
    背景:白色;
    }
    
    请将代码添加到问题中文档说明标签是出现在标记上的单个字符-尽管它似乎可以接受多个字符,但它是简单的文本。为什么不使用信息窗口?或者使用您想要的内容创建您自己的窗口?@RamRaider感谢您的回答。.代码在jsf中iddle.Im不允许显示链接..infowindow是最后的选择..我们之所以选择它作为最后的选择是因为要显示infowindow,您需要将鼠标悬停/单击到pin..我想删除红色的google pin..是的,如果我们使用infowindow,使用您的代码,我们可以删除pin。但是如果您查看我的JSFIDLE,我没有使用info别客气,谢谢你回来。
          /* Always set the map height explicitly to define the size of the div
           * element that contains the map. */
          #map {
            height: 90%;
          }
          /* Optional: Makes the sample page fill the window. */
          html, body {
            height: 100%;
            margin: 0;
            padding: 0;
          }
    
    <html>
        <head>
            <meta charset='utf-8' />
            <title>Google Maps: Infowindow with no marker</title>
            <script async defer src="//maps.google.com/maps/api/js?key=<API-KEY>&callback=initMap&region=en-GB&language=en"></script>
            <script>
                var map;
    
    
                function initMap(){
                    var infoWindow = new google.maps.InfoWindow({
                        maxWidth:100
                    });
                    var centre=new google.maps.LatLng( 55.959553, -3.178480 );
    
    
                    map = new google.maps.Map( document.getElementById('map'), {
                        zoom: 15,
                        center: centre,
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        disableDefaultUI: true
                    } );
    
    
                    infoWindow.setContent( "an infoWindow, centred on Edinburgh for no apparent reason, with no markers anywhere to be seen." );
                    infoWindow.setPosition( centre );
                    infoWindow.open( map, null );
                }
            </script>
    
            <style>
                body{ background:white;padding:0;margin:0; }
    
                #map {
                    width: 100%;
                    height:100%;
                    max-height: 100%;
                    clear:none;
                    display:block;
                    background:white;
                }
            </style>
        </head>
        <body>
            <div id='map'></div>
        </body>
    </html>