Giter Club home page Giter Club logo

yii2-openlayers's People

Contributors

circulon avatar sibilino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yii2-openlayers's Issues

Cannot get Widget to work

Having installed as stated in Readme, the browser console shows about 30 errors like:

[Error] Failed to load resource: Es wurde kein Server mit dem angegebenen Hostnamen gefunden. https://otile1-s.mqcdn.com/tiles/1.0.0/sat/4/9/7.jpg

Where is this Url coming from? Do I have to configure it in the extension?

Multiple Layers using short cut strings

I created a map with one tile layer and multiple vector layers. If I use the full vector layer specification all of the layers display properly, if I use the short cut layer specification only the tile and last vector layer is displayed.

in this example only the time layer and the last vector layer are displayed:
echo OpenLayers::widget([
'id' => 'lightning',
'options' => [],
'mapOptions' => [
'layers' => [
'Tile' => [ // Generates "new ol.layer.Tile()" JS. See below for an explanation of the OL class.
'source' => new OL('source.MapQuest', [
'layer' => 'sat',
]),
],
'Vector' => [
'source'=> new OL( 'source.Vector',[
'url' =>'/strikes2day_uncoor.json',
'format' => new OL('format.GeoJSON', [
'projection' => 'EPSG:3857',
]),
]),
],

        'Vector' => [
            'source' => new OL('source.Vector', [
                        'url' => '/strikes30day_test.kml',
                        'format' => new OL('format.KML', [
                            'projection' => 'EPSG:3857',
                             ]),
                        ])
                    ],
        'Vector' => [
            'source' => new OL('source.Vector', [
                        'url' => '/MasterCircle.kml',
                        'format' => new OL('format.KML', [
                            'projection' => 'EPSG:3857',
                             ]),
                        ])
                    ],
        'Vector' => [
            'source' => new OL('source.Vector', [
                        'url' => '/detectors.kml',
                        'format' => new OL('format.KML', [
                            'projection' => 'EPSG:3857',
                             ]),
                        ])
                    ],      

        ],

In this example all layers are displayed:

echo OpenLayers::widget([
'id' => 'lightning',
'options' => [],
'mapOptions' => [
'layers' => [
new OL('layer.Tile', [ // Generates "new ol.layer.Tile()" JS. See below for an explanation of the OL class.
'source' => new OL('source.MapQuest', [
'layer' => 'sat',
]),
]),

          new OL('layer.Vector', [
          'source'=> new OL( 'source.Vector',[
                       'url' =>'/strikes2day_uncoor.json',
                       'format' => new OL('format.GeoJSON', [
                            'projection' => 'EPSG:3857',
                             ]),
                        ]),
                    ]), 

              new OL('layer.Vector', [
                'source'=> new OL( 'source.Vector',[
                       'url' => '/strikes30day_test.kml',
                       'format' => new OL('format.KML', [
                            'projection' => 'EPSG:3857',
                             ]),
                        ]),
                    ]),             

              new OL('layer.Vector', [
                'source'=> new OL( 'source.Vector',[
                       'url' => '/MasterCircle.kml',
                       'format' => new OL('format.KML', [
                            'projection' => 'EPSG:3857',
                             ]),
                        ]),
                    ]), 

              new OL('layer.Vector', [
                'source'=> new OL( 'source.Vector',[
                       'url' => '/detectors.kml',
                       'format' => new OL('format.KML', [
                            'projection' => 'EPSG:3857',
                             ]),
                        ]),
                    ]), 

        ],

Am I misunderstanding the use of the short cut format ?
Otherwise the extension works great.

Thanks
Greg

Request : more example

Hello,

is it possible to have more example for using/configuring this widget ?

To be honest, I'm totally newbie in yii developpement and I meet many problem to understand how to use the widget.

I have a form with 2 textInput fields (latitude / longitude, in read only) and this widget.
My wish is when I clic on the map, a mark stay on this point and the fields are filled with the coordinates of it.

Can you help me ?

adding Javascript after the map definition

I am trying to implement the on.click functionality you pointed out in the previous issue and am having difficulty with defining it. Other then the on.click the map is working.

Here is the yii2 openlayer map definition:

echo OpenLayers::widget([
'id' => 'alertsite',
'options' => [],
// 'mapOptionScript' => 'olclick.js',
'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',
]),
]),

        ],
   '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 used the sibilino.olwidget.mapOptions to define the Overlay layer

$this->registerJs("
sibilino.olwidget.mapOptions['alertsite'] = {
overlay : new ol.Overlay({
name:'popup'
}) };
");

I then added the javascript for the on.click event

$this->registerJs("
alertsite.on('click', function(evt) {
var element = popup.getElement();
var coordinate = evt.coordinate;
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
coordinate, 'EPSG:3857', 'EPSG:4326'));

$(element).popover('destroy');
popup.setPosition(coordinate);
// the keys are quoted to prevent renaming in ADVANCED mode.
$(element).popover({
'placement': 'top',
'animation': false,
'html': true,
'content': '

The location you clicked was:

' + hdms + ''
});
$(element).popover('show');
});
");

I also tried changing the first line of the on.click to
sibilino.olwidget.mapOptions['alertsite'].on('click', function(evt) {

but got the same javascript error both times saying alertsite.on is not a function.

My thought is it is my confusion on how to name the function the same as the map.

Any thoughts ?
Thanks
Greg

cant get stylefunction to work

I am trying to implement a stylefunction on one of my vector layers.
I have tried several different ways to get it to work without success:

my vector layer:
new OL('layer.Vector', [
'name' => '30 Days',
'group' =>'Uncorr',
'visible' => false,

option one define style to point to a function described earlier in javascript

                'style' => 'function(feature,res){return strikestylefunction(feature,res);}',

option two tried using the new experimental ol.style.StyleFunction - it appears V3.10.1 does not have the experimental function included.
'style'=> new OL('style.StyleFunction',
['feature' => 'name',
'resolution'=> 'resolution',
'style'=>[
new OL('style.Style',[
'image' => new OL('style.Icon',[
'src' => '/bolt-9.png'
])
]),
],
]),

Any ideas how I should code the stylefunction ?

Thanks
Greg

Cannot get widget to display

I have a new yii2-advanced template setup
I added yii2-openlayers by composer
I added the code from the readme

<div id="test">
'test', 'mapOptions' => [ 'layers' => [ new OL('layer.Tile', [ // Generates "new ol.layer.Tile()" JS. See below for an explanation of the OL class. 'source' => new OL('source.MapQuest', [ 'layer' => 'sat', ]), ]), ], 'view' => [ // No OL() is required here because of simplified option support (see below) // 'center' => new JsExpression('ol.proj.transform([37.41, 8.82], "EPSG:4326", "EPSG:3857")'), 'zoom' => 4, ], ], ]);?>

and nothing is displayed.
I am relatively new to Yii2 however have expierence with OL3.
Can you provide some insight on what I may have done wrong ?
Also if I dont comment out the 'center; I get an error about JsExpression

Thanks

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.