【问题标题】:Another GMap Problem另一个 GMap 问题
【发布时间】:2009-11-06 12:55:46
【问题描述】:

过去一个小时我一直在查看这段代码,我不明白为什么 html 弹出窗口不会显示,我可能遗漏了一些简单的东西,因为没有报告错误。

var map;
var markers = new Array();
var geocoder;
function initialize() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(<?php echo $map_center; ?>), 17);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
            geocoder = new GClientGeocoder();   

    }
}

function createMarker(point,number) {   

    var marker = new GMarker(point);
    marker.value = number;

    GEvent.addListener(marker, "click", function() {

        map.openInfoWindowHtml(point, createInfoText());

    });     


    return marker;
}

function createInfoText() {
    var html = '<p>hello world</p>';
    return html;
}

$(document).ready(function () {
    initialize();
    var point = new GLatLng("51.2357, -0.5726");   
    map.addOverlay(createMarker(point,1));

});

提前谢谢大家

【问题讨论】:

    标签: javascript google-maps


    【解决方案1】:

    几行看起来有点时髦。

    这个:

    var point = new GLatLng("51.2357, -0.5726");
    

    应该是:

    var point = new GLatLng(51.2357, -0.5726);
    

    对于这个:

    map.setCenter(new GLatLng(<?php echo $map_center; ?>), 17);
    

    您应该确保$map_center, 分隔的两个浮点数字符串。

    【讨论】:

    • 我真的需要停止懒惰并写出代码大声笑谢谢 var point = new GLatLng(51.2357, -0.5726);解决了问题
    猜你喜欢
    • 1970-01-01
    • 2011-05-05
    • 2013-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多