Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm making a Openlayers map with some shapefile and I have Google Maps base layer. I want to create a text area and a button. When I input a address and click the button, the map should show me the google maps address in the map. Can you help me please ?

share|improve this question
Possible duplicate of… – Sunil Feb 27 '13 at 10:46
up vote 1 down vote accepted

this is my code

<script src=';v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>

function search(){
    //alert('search start');
    var address = document.getElementById('address').value+",Kathmandu, Nepal";
    var geocode_url=""

    //needs google api
    var geocoder = new GClientGeocoder();
    var location = geocoder.getLatLng(address,
        function(point) {
            if (!point) {
                alert(address + " not found");
            } else {
                //alert("going to "+address);
                var loc = new OpenLayers.LonLat(point.x,point.y);
share|improve this answer

Try the below code.

var geocoder = new google.maps.Geocoder();

geocoder.geocode({ 'address': address }, function (results, status) {

  if (status == google.maps.GeocoderStatus.OK) {
        else {
             console.log("Geocoding failed: " + status);                            
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.