google地图定位问题

    技术2022-05-19  28

      

    var geocoder; var map; function initialize() { geocoder=new google.maps.Geocoder(); var latlng=new google.maps.LatLng(-34.397,150.644); var myOptions={ zoom:8,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP }map=new google.maps.Map(document.getElementById("map_canvas"),myOptions); var query=document.getElementById("address").value; codeAddress('厦门'); }function codeAddress(query) { var address=query; geocoder.geocode({ 'address':address },function (results,status) { if(status==google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker=new google.maps.Marker({ map:map,position:results[0].geometry.location }); }else { alert("Geocode was not successful for the following reason: "+status); } }); } var geocoder; var map; function initialize() { geocoder=new google.maps.Geocoder(); var latlng=new google.maps.LatLng(-34.397,150.644); var myOptions={ zoom:8,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP }map=new google.maps.Map(document.getElementById("map_canvas"),myOptions); codeAddress('厦门'); }function codeAddress(query) { var address=query; geocoder.geocode({ 'address':address },function (results,status) { if(status==google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker=new google.maps.Marker({ map:map,position:results[0].geometry.location }); }else { alert("Geocode was not successful for the following reason: "+status); } }); }//codeAddress('厦门');

     

    看看这两段代码有什么本质上的差别没有,但是一个能够用来定位中文字符,一个不能够用来定位。

    什么原因?

    后来才发现是文本的存储格式方面的问题。要统一转成utf-8的才行。

    就像这段上写的。

    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>


    最新回复(0)