Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 24th, 2010, 01:49 AM
Registered User
 
Join Date: Oct 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Google maps Geocode

I read Imar's book - beginning Asp.net 3.5. It is a great book.
I then started building a website but i'm having issues with google maps javascript. I was trying out some sample code from Google's training but i keep getting the error on firebug - "google.maps.Geocoder is not a constructor"
for the line: geocoder = new google.maps.Geocoder();

I searched for the error online and found a few posting recommending - google.setOnLoadCallback() - to be used. But when i used that i seem to be getting more errors.

Below is the code for the entire page. Please let me know what's causing the error.

Thank you!

Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Maps2.aspx.cs" Inherits="Trial_Maps2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;
key=ABQIAAAAJufm5IbqOx3oHcWCrkcpPZyfNiLPHlJijQMANFPQ" 
type="text/javascript"></script>
    <script type="text/javascript">

  var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}



  function codeAddress() {
    var address = document.getElementById("address").value;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map, 
            position: results[0].geometry.location
        });
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
}
    
  </script>
</head>

<body onload="initialize()">
 <div id="map_canvas" style="width: 320px; height: 480px;"></div>
  <div>
    <input id="address" type="text" value="Sydney, NSW"/>
    <input type="button" value="Encode" onclick="codeAddress()"/>
  </div>
</body>
</html>
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
com.google.android.maps library unavailable lz1234 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 1 June 7th, 2009 10:18 AM
Hacked Bills Google Maps Code ramone_johnny Classic ASP Basics 5 August 5th, 2008 10:11 PM
Bills Whiz Bang Google Maps ramone_johnny Classic ASP Basics 2 August 1st, 2008 07:23 PM
Google Maps JS in ASPX page error kingroon ASP.NET 2.0 Basics 0 December 7th, 2007 09:52 AM
XSL, Javascript and Google maps.. tomharding XSLT 2 March 14th, 2007 06:10 PM



All times are GMT -4. The time now is 06:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.