开发者

Another GMap Problem

开发者 https://www.devze.com 2022-12-11 05:14 出处:网络
I have been looking over this code for the past hour, I cant see why html pop up will not show, I\'m probably missing something simple as no errors are reported.

I have been looking over this code for the past hour, I cant see why html pop up will not show, I'm probably missing something simple as no errors are reported.

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(poi开发者_开发知识库nt,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));

});

Thanks in advance all


Couple lines look a little funky.

This one:

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

should be:

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

And for this one:

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

you should ensure $map_center is a , separated string of two floats.

0

精彩评论

暂无评论...
验证码 换一张
取 消