0

我有一个要求,比如我有 300 多个纬度和经度。我需要的只是在地图上指出这些纬度和经度。那里的任何人都可以帮我解决这个问题。

到目前为止,我已经搜索了 google 和 SO,但一切都在 php、python 和其他中,但我需要它在 jquery 或 c# 或 xslt 中。任何帮助都是不言而喻的。

请不要投票,我是新来的地图工作..

4

2 回答 2

1

看看jVectorMapjQuery Mapael。或者,如果您真的想使用 Google 地图,请试试这个 JSFiddle:http: //jsfiddle.net/yV6xv/2987。代码应如下所示:

   <html>
    <head>
        <link rel="stylesheet" type="text/css" href="mystyle.css">
        <title="Hello"></title>
        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
        function initialize() {

            var locations = [
                [1.37265, 103.893658],
                [1.400617, 103.907833],
                [1.346002, 103.825436],
                [1.352051, 103.849125],
                [1.251226, 103.830757]
                ];

            var map = new google.maps.Map(document.getElementById('map'), {
                zoom: 11,
                center: new google.maps.LatLng(1.37265, 103.893658),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });

            var infowindow = new google.maps.InfoWindow();

            var marker, i;

            for (i = 0; i < locations.length; i++) {
                marker = new google.maps.Marker({
                    position: new google.maps.LatLng(locations[i][0], locations[i][1]),
                    map: map
                });
            }                                                            
        }
        google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    </head>
    <body>
        <!-- CHECK ELEMENT ID also UPDATE CSS -->
        <div id="map"></div>
    </body>
</html>
于 2013-10-28T06:10:20.547 回答
1

尝试这个

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var markers = [
<asp:Repeater ID="rptMarkers" runat="server">
<ItemTemplate>
            {
            "title": '<%# Eval("Name") %>',
            "lat": '<%# Eval("Latitude") %>',
            "lng": '<%# Eval("Longitude") %>',
            "description": '<%# Eval("Description") %>'
        }
</ItemTemplate>
<SeparatorTemplate>
    ,
</SeparatorTemplate>
</asp:Repeater>
];
</script>
<script type="text/javascript">
    window.onload = function () {
        var mapOptions = {
            center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
            zoom: 8,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var infoWindow = new google.maps.InfoWindow();
        var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
        for (i = 0; i < markers.length; i++) {
            var data = markers[i]
            var myLatlng = new google.maps.LatLng(data.lat, data.lng);
            var marker = new google.maps.Marker({
                position: myLatlng,
                map: map,
                title: data.title
            });
            (function (marker, data) {
                google.maps.event.addListener(marker, "click", function (e) {
                    infoWindow.setContent(data.description);
                    infoWindow.open(map, marker);
                });
            })(marker, data);
        }
    }
</script>
<div id="dvMap" style="width: 500px; height: 500px">
</div>

参考: http ://www.aspsnippets.com/Articles/Show-Google-Maps-using-Latitude-and-Longitude-in-ASPNet.aspx

于 2013-10-28T06:11:41.783 回答