【问题标题】:GoogleMaps and GeoIP: Get Lat,Long from IP and paint map?GoogleMaps 和 GeoIP:从 IP 获取 Lat、Long 并绘制地图?
【发布时间】:2012-03-25 20:15:18
【问题描述】:

我正在根据用户 ip 检索经度和纬度,然后我只想绘制地图,但它不会工作

function initialize() {
    console.log(geoip_latitude(), geoip_longitude());
    var myLatlng = new google.maps.LatLng(geoip_latitude(), geoip_longitude());
    var myOptions = {
        zoom: 8,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}


$(document).ready(function(){
    initialize();
});

萤火虫日志

google.maps.LatLng is not a constructor
[Parar en este error]   

var myLatlng = new google.maps.LatLng(geoip_latitude(), geoip_longitude());

知道为什么吗?

请在这里摆弄http://jsfiddle.net/As3JQ/12/

【问题讨论】:

    标签: javascript google-maps geoip


    【解决方案1】:

    主要代码似乎还可以,我看了你的jsfiddle,我所做的只是添加

    html, body, #map_canvas { height: 100% }​
    

    到 CSS 区域,它对我来说很好用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-20
      相关资源
      最近更新 更多