Comments (9)
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.
Please show you entire code or better — put it all in a fiddle.
from ol-geocoder.
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.
closed this by mistake
from ol-geocoder.
Change to ol-debug.js to a more verbose message. It seems to me that this is an OL issue.
from ol-geocoder.
"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.
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.
@daas-ankur-shukla I'm looking for how to fix this issue.
from ol-geocoder.
Ahh you have a typo: new Geocoder('nomatim'
should be nominatim
.
from ol-geocoder.
Related Issues (20)
- Toggle Marker in Options HOT 2
- Is the timeout necessary? HOT 1
- Firefox console issue TypeError HOT 1
- JS issue in Angular8 Project HOT 3
- Using Search Function Outside Div HOT 2
- TypeScript Typings, Exports
- Warning when using ol-geocoder from the CDN HOT 2
- Search Button - search does not work from smartphone if there is another text field HOT 6
- Remove search layer from legend HOT 3
- "countrycodes" option broken with array HOT 2
- Broken on Openlayers 7.1.0 HOT 23
- Limit search result to city HOT 2
- Allow custom URL for osm provider HOT 10
- URL for OSM provider is wrong HOT 1
- Init error on 4.2.0 HOT 3
- src/nominating.js better import on 4.2.0 HOT 1
- Error on bbox returned by nominatim.js 4.2.0 on Openlayers 7.4.0+ HOT 1
- Announcement: Transfer of Repository Ownership HOT 1
- How to customize original css style for geocoder text-input? HOT 5
- Tile layer is hidden by the marker layer in Openlayers 9.0.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ol-geocoder.