目的:ジオロケーションを使用してGoogleマップをレンダリングする。Drupal 7で解析エラーが発生する:構文エラー、予期しないT_STRING
私のサイトで以下の例を実装しようとしています。
http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding
の作業のデモ:http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-simple.html
私はhook_initの私drupal_add_js()(のコードを実装している)が、私は
解析エラーエラーを取得しています:構文エラー、予期しませんT_STRING in /home/vishal/public_html/dev/sites/all/modules/customvishal/customvishal.module on line 43
は次のコードです:
drupal_add_js('
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 address = "pune,india";
var latlng = new google.maps.LatLng();
geocoder = new google.maps.Geocoder();
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);
}
}
)。
」 アレイ( 'タイプ' => 'インライン'、 '' => 'ヘッダ範囲'、 'ウェイト' => 5)
)。
はいパーサーを混乱させる一重引用符でした。私は後ですべてのjsをsepファイルに入れます。 –