谷歌地图使用循环V3标志 [英] google maps v3 marker using loop

查看:126
本文介绍了谷歌地图使用循环V3标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌地图API V3,并希望使使用循环在JS标志也从Db.I显示在信息窗口中的数据要进行地图的标记为我添加一行到数据库。
这项工作已经FOT我这是波纹管,但我无法Compelete我的目标完成。

I am Using Google maps api v3 and want to make markers using loop in JS on also display the data on infowindow from Db.I want to make markers on map as i add row into DB. The work have i done fot this is bellow but i unable to Compelete my target.

<%  Dim con As New OleDbConnection
        con = New OleDbConnection("Data Source=sml; User ID=sml; Password=sml; provider=OraOLEDB.Oracle")
        con.Open()
        Dim cmd As OleDbCommand = New OleDbCommand("Select STA_NAME, GPS_ONE from GPS", con)

        Dim ds As New DataSet
        Dim I As Long
        Dim da As New OleDbDataAdapter(cmd)
        da.Fill(ds, "GPS")
        For I = 0 To ds.Tables("GPS").Rows.Count - 1
            Dim GPS As String = ds.Tables("GPS").Rows(I).Item("GPS_ONE")
        Next

        %>

和map函数JS code键使标记

And JS code in map function to make marker

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

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


var GPS='<%=GPS %>'

var Infowindow=GPS

var image = 'ico/Ch.png';
var LatLng = new google.maps.LatLng(GPS);
var marker0 = new google.maps.Marker({
    draggable: true,
    position: LatLng,
    map: map,
    icon:image,
    title:""

});

google.maps.event.addListener(marker0, 'click', function() {
infowindow.setContent(Infowindow);
  infowindow.open(map,marker0);

});

通过这个code我是unalbe使连一个marker.I要在地图上标记创建正如我在DB列中添加GPS

Through this code i am unalbe to make even one marker.I want to create marker on map as i add GPS in DB Column

推荐答案

google.maps.LatLng需要的两个的参数。您正在使用: GPS 的。既然你不说有什么价值的 GPS 的样子,这应该让你开始。

google.maps.LatLng requires two arguments. You are using one: GPS. Since you don't say what the value of GPS looks like, this should get you started.

替换:

var GPS='<%=GPS %>'

var GPS = '<%=GPS %>'.replace(/ /g, '').split(',');

替换:

var LatLng = new google.maps.LatLng(GPS);

var LatLng = new google.maps.LatLng(GPS[0], GPS[1]);

这篇关于谷歌地图使用循环V3标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆