我有一張地圖,我正在嘗試做的是在信息窗口中獲取一些表格。我已經通過混合java腳本和php(其中我都不熟悉)來實現這一點。所以我的問題是爲什麼我的地圖不顯示?當我去查看源代碼時,所有的東西都是我想要的,但卻是愚蠢的,導致地圖不能顯示。我已經發布了下面的代碼,希望更有技巧的眼睛能夠解決這個問題。請放輕鬆我,我只有約6個月的編碼,仍然犯了很多錯誤。爲什麼我的地圖沒有加載
所以我遇到的問題是這部分
"<?php
$cnt = 0;
foreach ($default_properties as $prop_key => $value) {
?>"
'<div class="view-row">'
'<div class="view-label">'."<?php echo $prop_key?>".'</div>' +;
'<div class="view-value">'. "<?php echo $value?>".'</div>' +;
'</div>'; "<?php
$cnt++;
}
if ($node_id > 0) {
foreach ($node_values as $prop_key => $value) {
?>"
'<div class="view-row">'
'<div class="view-label">'."<?php echo $prop_key?>".'</div>' +;
'<div class="view-value">'. "<?php echo $value?>".'</div>' +;
'</div>';<?php
$cnt++;
}
}
?>"
我可以操控上面的部分,使得串負荷,但我就不能格式化。這樣它格式正確,但不加載地圖。但是當我查看地圖的源代碼時,一切都在那裏!所以我很困惑。下面
<script type="text/javascript">
var infowindow = new google.maps.InfoWindow();
var browserSupportFlag = new Boolean();
function initialize()
{
var latlng = new google.maps.LatLng(38.9550040,-77.4045560);
var settings =
//sets the settings of the map
{
zoom: 5,
center: latlng,
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
geocoder = new google.maps.Geocoder();
map = new google.maps.Map(document.getElementById("map_canvas"), settings);
// Try W3C Geolocation (Preferred)
if(navigator.geolocation)
{
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position)
{
initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
}, function()
{
handleNoGeolocation(browserSupportFlag);
});
}
// Browser doesn't support Geolocation
else
{
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
function handleNoGeolocation(errorFlag)
{
if (errorFlag == true)
{
alert("Geolocation service failed.");
initialLocation = Virgina;
}
else
{
alert("Your browser doesn't support geolocation. We've placed you in here.");
initialLocation = '';
}
map.setCenter(initialLocation);
}
}
// Takes an address and places a marker in google maps
function codeAddress()
{
var address = "<?php echo $node_address?>";
var description = "<?php echo $node_title?>";
var property = "<?php echo $default_properties?>";
var values = "<?php echo $node_values?>";
<?php
$js_array = json_encode($end_node_addresses);
echo "var end_addresses = ". $js_array . ";\n";
?>
var image = "<?php echo $entity_icon?>";
geocoder.geocode({ 'address': address}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
map.setCenter(results[0].geometry.location);
var contentString = '<div id="contentmarker">'+
'<div id="siteNotice">'+
'</div>'+
'<h2 id="firstHeading" class="firstHeading"><?php echo $node_title?></h2>'+
'<div id="bodyContent">'+
'<p> Is a <?php echo $entity_name?> located in<?php echo $node_address?></br> "<?php
$cnt = 0;
foreach ($default_properties as $prop_key => $value) {
?>"
'<div class="view-row">'
'<div class="view-label">'."<?php echo $prop_key?>".'</div>' +;
'<div class="view-value">'. "<?php echo $value?>".'</div>' +;
'</div>'; "<?php
$cnt++;
}
if ($node_id > 0) {
foreach ($node_values as $prop_key => $value) {
?>"
'<div class="view-row">'
'<div class="view-label">'."<?php echo $prop_key?>".'</div>' +;
'<div class="view-value">'. "<?php echo $value?>".'</div>' +;
'</div>';<?php
$cnt++;
}
}
?>" <b></b></p>'+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow(
{
content: contentString
});
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
icon: image,
title: address
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
else
{
alert("Geocode was not successful for the following reason: " + status);
}
});
var title_vars = end_addresses;
for (i = 0; i < end_addresses.length; i++)
{
geocoder.geocode({ 'address': end_addresses[i]}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
map.setCenter(results[0].geometry.location);
var contentString = '<div id="contentmarker">'+
'<div id="siteNotice">'+
'</div>'+
'<h2 id="firstHeading" class="firstHeading"><?php echo $node_title?></h2>'+
'<div id="bodyContent">'+
'<p> Is located in "<?php echo $js_array?>"</p>'+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
icon: image,
title: title_vars.shift(),
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
else
{
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
</script>
什麼都是圍繞單引號和雙引號你的代碼? – Kermit
我被告知我需要他們。某處我認爲這是我無法找到的問題。 – user1639669