Code Monkey home page Code Monkey logo

Comments (9)

thisisashukla avatar thisisashukla commented on May 13, 2024 1

oh my god. i am sorry to have wasted your time jonataswalker. thank you for your support and the good work of ol3-geocoder

from ol-geocoder.

jonataswalker avatar jonataswalker commented on May 13, 2024

Please show you entire code or better — put it all in a fiddle.

from ol-geocoder.

thisisashukla avatar thisisashukla commented on May 13, 2024

here is the full code

<!DOCTYPE html>

<html>
<head>
  <title>Map Page</title>
  <link rel="stylesheet" href="https://openlayers.org/en/v3.20.0/css/ol.css" type="text/css">
  <style>
  .map{
    height:400px;
    width:400px;
  }</style>
  <script src="https://openlayers.org/en/v3.20.0/build/ol.js" type="text/javascript"></script>
  <link href="//cdn.jsdelivr.net/openlayers.geocoder/latest/ol3-geocoder.min.css" rel="stylesheet">
  <script src="//cdn.jsdelivr.net/openlayers.geocoder/latest/ol3-geocoder.js"></script>
  </head>
<body>
  <div id="map" class="map"></div>
  <div id="overlay"></div>
 </body>

  <script type="text/javascript">
  function el(id){
    return document.getElementById(id);
  };

var zoomlevel=5;


  var center = ol.proj.transform([80,20], 'EPSG:4326', 'EPSG:3857');

  var view = new ol.View({
    center: center,
    zoom: zoomlevel
  });

  var featureSource = new ol.source.Vector({});
  var osmSource = new ol.source.OSM();

  var layer = [new ol.layer.Tile({
    source: osmSource
  }),
  new ol.layer.Vector({
    source:featureSource
  })
];

  var overlay1=new ol.Overlay({
    element:el('overlay'),
    positioning:'bottom-center'
  });



  var map = new ol.Map({
    //renderer can be set to 'canvas', 'dom' or 'webgl'
    renderer: 'canvas',
    target: 'map',
    layers: layer,
    view: view
  });

  var geocoder=new Geocoder('nomatim',{
    provider:'osm',
    key:'',
    lang:'en-US',
    placeholder:'Search Destination...',
    limit:5,
    countrycodes:'in',
    keepOpen:false,
    preventDefault:true
  });

  map.addControl(geocoder);

  var p="point";


  geocoder.on('addresschosen', function(evt) {
    // it's up to you
    var coordinates=evt.coordinate;
    var degrees = ol.proj.transform(coordinates, 'EPSG:3857', 'EPSG:4326');
    console.info(degrees);
    // format a human readable version
    var hdms = ol.coordinate.toStringHDMS(degrees);



    numOfPoints+=1;
    var point= new ol.Feature();
    point.setId(p.concat(numOfPoints.toString()));
    point.setStyle(pointStyle);

    point.setGeometry(coordinates ?
      new ol.geom.Point(coordinates) : null);
      zoom=14;

    featureSource.addFeature(point);
    doPan(coordinates);
  });

  </script>```

from ol-geocoder.

thisisashukla avatar thisisashukla commented on May 13, 2024

closed this by mistake

from ol-geocoder.

jonataswalker avatar jonataswalker commented on May 13, 2024

Change to ol-debug.js to a more verbose message. It seems to me that this is an OL issue.

from ol-geocoder.

thisisashukla avatar thisisashukla commented on May 13, 2024

"Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
at t.ol.control.Control.setMap (ol-debug.js:13106)
at ol.Map. (ol-debug.js:41234)
at ol.Collection.boundListener (ol-debug.js:3441)
at ol.Collection.ol.events.EventTarget.dispatchEvent (ol-debug.js:3859)
at ol.Collection.insertAt (ol-debug.js:12466)
at ol.Collection.push (ol-debug.js:12490)
at ol.Map.addControl (ol-debug.js:41303)
at loc:182"

with ol-debug.js

from ol-geocoder.

thisisashukla avatar thisisashukla commented on May 13, 2024

i raised this issue as openlayer issue 6318 repository but they asked me to report it here. what can be the possible reason for this problem?
thanks in advance

from ol-geocoder.

jonataswalker avatar jonataswalker commented on May 13, 2024

@daas-ankur-shukla I'm looking for how to fix this issue.

from ol-geocoder.

jonataswalker avatar jonataswalker commented on May 13, 2024

Ahh you have a typo: new Geocoder('nomatim' should be nominatim.

from ol-geocoder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.