Comments (5)
Just an update. I copied from a backup the old yii2-openlayers code, made a few changes to add the overlay layer using the typical javascript way of adding the layer, and everything worked ok. I then recopied in the new yii2-openlayer code and it didnt work (just wanted to make sure the changes I made didnt fix the issue).
For now I will continue with the old code so I can continue with my project.
Greg
from yii2-openlayers.
The map objects are no longer accessible as a plain javascript variable, so
"alertsite" is undefined. You would need to define it as var alertsite = sibilino.olwidget.getMapById("alertsite")
. The goal was to put everything
under the sibilino global namespace so that there are no collisions with
existing variables.
Seems that I forgot to explain all this in the documentation, so I will
update it soon.
However, I don't really understand what you are doing with that popup
overlay. Isn't it better to define it in PHP? Looks like a single OL()
would suffice.
2016-01-02 3:55 GMT+01:00 gursel58 [email protected]:
—
Reply to this email directly or view it on GitHub
#7 (comment).
from yii2-openlayers.
I did try using the new OL(.. to define the Overlay layer and I got a JavaScript error
TypeError: b.nf is not a function in ol.js(line 206,col 81)
here is the code I had to define the map with Overlay
echo OpenLayers::widget([
'id' => 'alertsite',
'options' => [],
'mapOptions' => [
'layers' => [
new OL('layer.Tile', [ // Generates "new ol.layer.Tile()" JS. See below for an explanation of the OL class.
'name' => 'base',
'source' => new OL('source.MapQuest', [
'layer' => 'sat',
]),
]),
new OL('Overlay' ,[
'name' => 'popup',
'element' => "document.getElementById('popup')",
]),
],
'view' => [ // No OL() is required here because of simplified option support (see below)
'center' => new JsExpression('ol.proj.transform([-114.0, 51.0], "EPSG:4326", "EPSG:3857")'),
'zoom' => 8,
'projection' => 'EPSG:3857'
],
],
]);
I did try and use
var alertsite=sibilino.olwidget.getMapById("alertsite");
and I got a
ReferenceError:maps is not defined in olwidget.js (line 27,col 13)
Thanks
Greg
from yii2-openlayers.
Ok, the getMapById function is bugged then. I will release a fix as soon as
I can.
For the moment you can use var
alertsite=sibilino.olwidget.maps["alertsite"].
Regarding your overlay, you are defining it inside the "layers" array. It
should be in a separate array with the key "overlays". In addition, you are
passing JavaScript as its "element" configuration, but you are giving a
simple string, while you should be using a JsExpression: "element" => new
JsExpression("document.getElementById('popup')"),
2016-01-06 1:32 GMT+01:00 gursel58 [email protected]:
I did try using the new OL(.. to define the Overlay layer and I got a
JavaScript errorTypeError: b.nf is not a function in ol.js(line 206,col 81)
here is the code I had to define the map with Overlayecho OpenLayers::widget([
'id' => 'alertsite',
'options' => [],'mapOptions' => [
'layers' => [
new OL('layer.Tile', [ // Generates "new ol.layer.Tile()" JS. See below
for an explanation of the OL class.
'name' => 'base',
'source' => new OL('source.MapQuest', [
'layer' => 'sat',
]),
]),
new OL('Overlay' ,[
'name' => 'popup',
'element' => "document.getElementById('popup')",
]),
],
'view' => [ // No OL() is required here because of simplified option
support (see below)
'center' => new JsExpression('ol.proj.transform([-114.0, 51.0],
"EPSG:4326", "EPSG:3857")'),
'zoom' => 8,
'projection' => 'EPSG:3857'
],
],
]);I did try and use
var alertsite=sibilino.olwidget.getMapById("alertsite");
and I got a
ReferenceError:maps is not defined in olwidget.js (line 27,col 13)Thanks
Greg—
Reply to this email directly or view it on GitHub
#7 (comment)
.
from yii2-openlayers.
getMapById works
Thanks
from yii2-openlayers.
Related Issues (6)
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 yii2-openlayers.