谷歌地图StyledMarker不再工作

时间:2016-06-07 07:57:33

标签: google-maps-api-3

我的网页如this一个,使用StyledMarker,过去工作正常,但是大约一个月(?)之前就失败了。 Firefox控制台提供

ReferenceError: StyledMarker is not defined

这里

function initialize() {   var mapCanvas = document.getElementById('map');   var mapOptions = {center:new google.maps.LatLng(latitudeMid,longitudeMid),mapTypeId:google.maps.MapTypeId.ROADMAP,streetViewControl:false,mapTypeControl:true,scaleControl:true,scaleControlOptions:{position:google.maps.ControlPosition.TOP_RIGHT}}; usefulWidth=window.innerWidth-50;   map = new google.maps.Map(mapCanvas, mapOptions);   var i;   var insertion;   var previousMarker;   var previousZindex;   document.getElementById('zoemCheck').checked=false;   for (i = 0; i < fotoCount; i++)  { 
    var myLatLng =new google.maps.LatLng(Latituden[i], Longituden[i]); 
    //===========================================================================================================================
    var marker = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.MARKER,{color:'00ff00',text:Letters[i]}),position:myLatLng,map:map});
    //===========================================================================================================================
    bounds.extend(myLatLng);
    marker.set('zIndex', -i);
    marker.myIndex = i;
    markers.push(marker);
    google.maps.event.addListener(marker, 'click', function() {
      if(previousMarker!=null)
        {
        previousMarker.styleIcon.set('color', '00ff00');
        previousMarker.set('zIndex', previousZindex);
        previousZindex=this.zIndex;
        }
      this.styleIcon.set('color', 'ff0000');
      this.set('zIndex', google.maps.Marker.MAX_ZINDEX+1);
      thisMarker=this.myIndex;
      if (zoem==1) //moet nu inzoemen
        {
        map.setCenter(new google.maps.LatLng(Latituden[thisMarker], Longituden[thisMarker]));
        map.setZoom(18);
        }
      if (zoem==2) //moet nu uitzoemen
        {
        map.setCenter(new google.maps.LatLng(latitudeMid,longitudeMid));
        map.setZoom(myZoom);
        zoem=0;
        }
      var insertion="";
      insertion='<img src=\"http://www.pdavis.nl/Ams/'.concat(Bestanden[this.myIndex],'.jpg \" id=\"myImg\" onLoad=\"imgEvent()\"></img>'); 
      insertion=insertion.concat('<table class=width100><tr><td>Bestand: ',Bestanden[this.myIndex],'</td><td class=pright>Lokatie: ',Latituden[this.myIndex],' °N., ',Longituden[this.myIndex],' °E. (',Letters[this.myIndex],')</td>');
      insertion=insertion.concat('<td class=pright>Genomen: ',Datums[this.myIndex],'</td></tr><td colspan=3>Object: ',Objecten[this.myIndex],'</td></table>');
      $('#photo').html(insertion);
      previousMarker=this;
      document.getElementById('myImg').style.width = '100%';
      });    google.maps.event.addDomListener(document.getElementById('volgende'), 'click', nextEvent);    google.maps.event.addDomListener(document.getElementById('vorige'), 'click', previousEvent);    google.maps.event.addDomListener(document.getElementById('zoemer'), 'click', zoemerEvent);    google.maps.event.addDomListener(document.getElementById('totaal'), 'click', totaalEvent);    }     map.fitBounds(bounds);   google.maps.event.trigger(markers[0], 'click');   document.getElementById('header').style.width = (window.innerWidth-20)
+ "px";   document.getElementById('vorige').style.left = ((window.innerWidth/2)-295) + "px";   document.getElementById('volgende').style.left = document.getElementById('vorige').offsetLeft + 90 + "px";   document.getElementById('selectie').style.left = (window.innerWidth-910) + "px";   if (window.innerWidth<1920)
    {
    document.getElementById('map').style.width = 0.40 * usefulWidth + 'px';
    document.getElementById('photo').style.width = 0.60 * usefulWidth + 'px';
    }   FillSelecters(); }

我包括

<script src="https://maps.googleapis.com/maps/api/js"></script>
<script type="text/javascript" src="https://google-maps-utility-library-v3.googlecode.com/svn/trunk/styledmarker/src/StyledMarker.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 

我无法找到对这些脚本中最近更改的任何引用。我是否需要包含其他脚本?

1 个答案:

答案 0 :(得分:1)

网址https://google-maps-utility-library-v3.googlecode.com/svn/trunk/styledmarker/src/StyledMarker.js不再存在。 大多数项目转移到GitHub,但我无法在新网站上找到StyledMarker项目。 但仍然可以找到来源herehere。要么替换

<script type="text/javascript" src="https://google-maps-utility-library-v3.googlecode.com/svn/trunk/styledmarker/src/StyledMarker.js"></script>

<script type="text/javascript" src="https://cdn.rawgit.com/jacopotarantino/google-maps-utility-library-v3/master/styledmarker/src/StyledMarker.js"></script>

或者您将脚本复制到您自己的项目中,这样您就不必依赖任何存储库在线(我建议)。