开发者

google maps and ASP

开发者 https://www.devze.com 2023-01-07 23:05 出处:网络
I am very new to ASP and I have some small project to do, so I some help. I need to write asp page that will read latitudes and longitudes from database and place markers on the map.

I am very new to ASP and I have some small project to do, so I some help. I need to write asp page that will read latitudes and longitudes from database and place markers on the map. This is my current code

    function initialize() {

    // initialize the map
    var latlng = new google.m开发者_StackOverflowaps.LatLng(-25.363882,131.044922);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    // define custom image
 var image = 'Computer.GIF';

    // load data from db
    <%
        conn=Server.CreateObject("ADODB.Connection");
  conn.Provider="Microsoft.Jet.OLEDB.4.0";
  conn.Open("c:/webdata/dbATMManager999.mdb");
  rs=conn.execute("select * from ATM WHERE LATITUDE IS NOT NULL AND LONGITUDE IS NOT NULL");
        while( !rs.eof ) {
    %>
            var currLatLng = new google.maps.LatLng(<%rs.Fields("LATITUDE");%>, <%rs.Fields("LONGITUDE");%>);
            var customMarker = new google.maps.Marker({
          position: currLatLng,
          map: map,
          icon: image
         });
    <%      rs.movenext();
        ...

this line new google.maps.LatLng(<%rs.Fields("LATITUDE");%>, <%rs.Fields("LONGITUDE")%>); causes the problem. For some reason I get runtime error: Microsoft JScript runtime error: Wrong number of arguments or invalid property assignment


Your longitude and latitude are not being written to the page. You need to add "=" symbols to Response.Write the latitude and longitude. <%=rs.Fields("LATITUDE") %> is equivalent to <% Response.Write("Test") %>.

Here's the change you need to make.

var currLatLng = new google.maps.LatLng(<%rs.Fields("LATITUDE");%>, <%rs.Fields("LONGITUDE");%>);

to

var currLatLng = new google.maps.LatLng(<%=rs.Fields("LATITUDE");%>, <%=rs.Fields("LONGITUDE");%>);
0

精彩评论

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