Code Monkey home page Code Monkey logo

leaflet-plugins's Introduction

Leaflet plugins

What ?

Miscellaneous Leaflet plugins for services that need to display route information and need satellite imagery from different providers. Currently it consists of:

  • Vector layers (layer/vector/):

    • GPX
    • KML
    • TOPOJSON
  • Providers implemented with respect to terms of use (layer/tile):

    • Yandex - using Yandex Maps API v2;
    • Bing - with proper attribution.
  • Control (control/):

    • Permalink - OpenLayers compatible permanent link with support for storing location data in hash part (#lat=...);

Compatibility

  • Tested with: Leaflet 1.0.x
  • For use with Leaflet 0.7.x see v2 branch

Where ?

Homepage : https://github.com/shramov/leaflet-plugins

Downloads : https://github.com/shramov/leaflet-plugins/releases

npm : https://www.npmjs.org/package/leaflet-plugins

cdnjs : https://cdnjs.com/libraries/leaflet-plugins

leaflet-plugins's People

Contributors

andrewshadura avatar brunob avatar buche avatar cschell avatar dependabot[bot] avatar duthils avatar elidupuis avatar emehmet avatar ershkus avatar fiskus avatar hna61 avatar jekuno avatar jywarren avatar kent1d avatar luiscamachopt avatar nexushoratio avatar nmccready avatar opie avatar originalsin avatar packowitz avatar pkalliok avatar raffas avatar rickselby avatar seregamatin avatar shramov avatar skruppy avatar stefanocudini avatar stilltorik avatar voda avatar williammcrae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet-plugins's Issues

Problem with Google Terrain as basemap

I also added Google Terrain in my plugin - please see www.mapsmarker.com, second map and switch in the layers control to google terrain. Problem is, that you cant move the map around - only the address overlay moves. With other Google map types, this works fine. Dave (https://github.com/robertharm/Leaflet-Maps-Marker/issues/31) ment that this has to to with missing max-zoom for terrain maps - so I added maxZoom:20 - but with no effect. Do you have any idea, why Google terrain maps dont work like the other ones?

Loading a layer from a kml file

Hi, I have been trying to add a layer from a kml file without succes. I've tried many things but nothing works. I only have a simple card without any layer added. I would be thankful if you could help me. here is my html code:

<script src="Leaflet/leaflet.js"></script> <script src="leaflet-plugins/layer/vector/KML.js"></script> <script type="text/javascript" > function initmap() { // set up the map var map = new L.Map('map'); // create the tile layer with correct attribution var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; var osmAttrib='Map data © OpenStreetMap contributors'; map.attributionControl.setPrefix(''); // Don't show the 'Powered by Leaflet' text. var osm = new L.TileLayer(osmUrl, {minZoom: 2, maxZoom: 16, attribution: osmAttrib}); // start the map in France map.setView(new L.LatLng(45.4, 1.2),6); map.addLayer(osm); // add a kml layer var kmlLayer = new L.KML("offresRoute.kml", {async: true}); kmlLayer.on("loaded", function(e) { map.fitBounds(e.target.getBounds()); }); map.addLayer(kmlLayer); } </script>

 

TEXTE DIV

compatibility with leaflet v0.4.4?

Hi Shramov,

I just try to upgrade my plugin mapsmarker.com (integrated with your plugin) to leaflet v0.4.3. Unfortunately bing maps dont show up anymore. I couldnt figure out if the error is caused by my plugin or if by bing.js.

Can you please tell me, if your current code is compatible with leaflet v0.4.4?
many thanks in advance for your help!

Robert

Object map._controlCorners['bottomright'] doesn't exist.

Object map._controlCorners['bottomright'] doesn't exist. But Object map._controlCorners['bottomRight'] does.

Old:
row 46: map._controlCorners['bottomright'].style.marginBottom = "1em";
row 59: map._controlCorners['bottomright'].style.marginBottom = "0em";

New:
row 46: map._controlCorners['bottomRight'].style.marginBottom = "1em";
row 59: map._controlCorners['bottomRight'].style.marginBottom = "0em";

KML loading issue

Hello Pavel,
First, thanks for the KML plugin. I really look forward to using it.
There's an issue when loading KML files that come from ESRi's systems (I think). Below is a link to such file, that causes an internal error in the plug in. The file loads on OpenLayers, GoogleEarth and a parser I wrote for iOS, so I guess it is OK(-ish?). I'm be happy to collaborate on this, as I'll be much happier using leaflet than the other options.

http://ec2-54-218-4-137.us-west-2.compute.amazonaws.com/assets/kmls/tour.kml

The error is on line 210 of KML.js:

TypeError: 'undefined' is not an object (evaluating 'el[0].childNodes[0].nodeValue')

Thanks,
Michael

Something wrong with Google/Yandex

Привет. Во время интеграции возникла трабла - тайлов не видно http://tinyurl.com/chyzsax . При этом opencyclemap нормально отображается, а гуглокарты и яндекскарты - нет. Возможно как-то связанно с версткой на странице, но я не могу понять что не так.

GPX plugin works?

I cannot make it run. Even example does not show GPX.
It does not show any trace of problems except loaded GPX is not visible.

JavaScript Error Console shows no errors.

Other plugins from the pack work fine.

I also did not manage to display KML either using KML.js.

Is there problem with code or I am not smart enough to figure it out?

Leaflet KML plugin does (not) work depending on location of files

Hello Shramov,

I tried using your KML plugin, but I've got a strange behavior.

First, I tried to use local leaflet and leaflet-plugin scripts, with a local HTML.

Then when I saw it didn't work, I copied your example at
http://psha.org.ru/leaflet-plugins/examples/kml.html
and put the exact same content at
http://www.tellnet.fr/blog/kmlsource.html,
just modifying the paths toward your files on your server.

Well, when I open yours, it works perfectly : it centers on USA and shows the markers.
When I open mine, it always center on Russia and never displays any marker.

I've got no errors anywhere. I'm not even sure it's related to your plugin, maybe it's related to the Leaflet JS, but I don't see what it can be.

Thank you very much in advance for your help.

PS : I'm a noob in JS.
PSS : I guess it's somehow related to these issues :
#43
#36

kml file is not loaded.

var track = new L.KML("KML_Samples.kml", {async: true});
track.on("loaded", function(e) { alert("hi"); map.fitBounds(e.target.getBounds()); });
is it because i am testing it locally do i need to put it on a server? the alert is never called? i dont see the data from xml

markers with google tiles are out of sync for me

Hello,
amazing work

when adding markers to leaflet it renders find with OSM but when using google the markers are repositioned before the map repositions. I don't know if I done something wrong or it is a known issue

Google.js is conflict with doc indicated as HTML5

Hello there,

google.html from examples folder is working pretty good, but once I indicated the doc as HTML5 then the Google tile will not load any more. I have filed a snippet at https://gist.github.com/3968924 then you could play it around by defining it as HTML5 type to see what will happen.

I did test against Chrome v22 & Safari v5.1.7

Thank you for your time.

/Xinyu

Markers on Yandexmap

При добавлении маркера на карту, маркер отображается только на OSM. На карте Yandex маркер не виден.

    var map = L.map('map').setView([57,1], 13);
    var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');

    var layerdefs = {
        ysat: { name: "Yandex", js: ["/scripts/tile/Yandex.js", "http://api-maps.yandex.ru/2.0/?load=package.map&lang=ru-RU"],
            init: function() {return new L.Yandex("satellite"); }},
    };

    var yndx = new L.DeferredLayer(layerdefs.ysat);
    map.addLayer(osm);
    map.addControl(new L.Control.Layers({'OSM':osm,  "Y":yndx},
                        {}));

    L.marker([57,1]).addTo(map)
        .bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();

Trouble with bing maps integration

Hi Shramov,

first thanks a lot for your great plugins! I am the developer of http://www.mapsmarker.com and since 2.5 of my plugin I use your Google Maps leaflet plugin successfully (one hint: you could also add terrain as list of possible basemaps).

With v2.6 I also integrated bing maps support. I therefore trippled the classes as I wanted all type of bing maps to be available (ok their could be better ways doing this, but this was the easiest for me due to my lack of deep javascript knowledge ;-) See the file here: http://www.mapsmarker.com/wp-content/plugins/leaflet-maps-marker/js/bing.js

When creating maps on admin backend, everything worked fine - no console errors, switching back and forth from other basemaps without problems. I made a v2.6 release and noticed (too late), that there are problems displaying bing maps with your plugin active on frontend. When calling the demo page (map 2 is bing map) on http://mapsmarker.com/bing, I am getting the following errors in the console:

TypeError: _bing_metadata is not a function
TypeError: _bing_metadata2 is not a function
TypeError: _bing_metadata3 is not a function

Sometimes also switching from bing basemaps to other basemaps doesnt work (cant be reproduced everytime) .

As said before, this only occurs on frontend and not within the admin area. I checked twice (or more often) - the implemenation of bing.js is the same on frontend as on backend.

As v2.6 with bing maps support is already out (although not enabled by default), I kindly ask you to help me solving this issue. Any help is really appreciated and I will give you proper credits within the plugin and on my websites (I already linked your plugin page within the plugins credits & help section).

Looking forward to hearing from you!

Robert

Accessing KML Data

Hello, can you tell me the correct or at least the preferred way to get the data out of the KML?

I have something that looks like this in my KML:

<Folder>
        <name>Events</name>
        <open>1</open>
        <Placemark>
            <name>Lunch Special</name>
            <LookAt>
                <longitude>23.75231752313513</longitude>
                <latitude>17.95077511438697</latitude>
                <altitude>0</altitude>
                <heading>-10.84185156357546</heading>
                <tilt>0</tilt>
                <range>10298789.70698782</range>
                <gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
            </LookAt>
            <styleUrl>#m_ylw-pushpin0</styleUrl>
            <Point>
                <coordinates>23.75231752313513,17.95077511438697,0</coordinates>
            </Point>
        </Placemark>

and I'm really justr trying to get the out of it to be used. I see it's put into the popup as an h2 but i'd like to do something keyed against that...

e.target.eachLayer(function(outerLayer) {
    outerLayer.eachLayer(function(innerLayer) {
      console.log(innerLayer);
    });
  });

etc... but it seems kind of ridiculous, like there's probably a better way. Can you advise?

в линейке косяк с удаление точек

в линейке косяк с удаление точек:
-создаем маршрут из >3 точек
-удаляем последнюю
-еще раз удаляем последнюю, получаем полупрозрачную точку висящую в воздухе
-а если еще и щелкнуть два раза на этой точке, получим вообще что-то странное

пробовал в опере и файерфоксе

http://forum.openstreetmap.org/viewtopic.php?pid=249507#p249507

Google maps layer zIndex

Hi again,

I'm currently having an issue with google maps tile layer. I'm using danzel's Leaflet.markercluster plugin to cluster and display my markers.

Problem is that google maps layer displays on top of marker layer so it renders the map unusable because it's impossible to click on markers.

When I select different tile layer (e.g. Bing layer or OSM) markers are displayed as intended on top of the tile layers. But if google maps tile layer is selected it's again displayed above all else.

Is it possible to move google tile layer to front or to back by some method? I've tried bringToFront() but L.Google doesn't have that method.

I'm sorry that I cannot give you a link to my webpage for security reasons to see it for yourself.

Google TOS?

According to this, one should not be able to use the map outside of google's tools.

Yet, I can still do:

  var road = new L.Google("ROADMAP");

or

  var road = new L.Google("SATELLITE");

And get access to the map with either street or satellite view.

So I'm wondering, how are you doing it? By using the script, would I be actually breaking any rule?

Cheers, and thanks for this great tool mate!

Selecting culture in BingLayer

You should add an additional attribute to BingLayer options so that cultures can be selected. When using type "Road" or "AerialWithLabels" there are tiles with localized labels.

IE7 compatibility?

Hi shramov,
a user of my plugin reported that Google Maps cannot be displayed with IE7. Can you please tell me if your plugin is IE7 compatible? would help me a lot where to look for a fix...
best regards,
Robert

Permalink: repeated params whith useAnchor=false

Permalink with useAnchor=false uses ? instead of # as delimiter between base URL and parameters. But the parameters are added twice ore more if Permalink is clicked again.

The cause is in _set_urlvars (lPermalink.js, line 98) where # is used regardless off the option useAnchor=true/false

BTW: thanks for your plugins!

Тормозят маркеры при просмотре карты

Ссылка на демо все та же - http://tinyurl.com/chyzsax . Если переключиться на Гугл и особенно на Яндекс - при перетягивании карты маркер перемещается, но с сильными такими тормозами. При этом на opencyclemap такого лага не наблюдается.

Ничего, что я по-русски?)

Permalink: Added support for overlays

I've added support for overlays in my project (sorry, no github pull request availabe).

It works using flags (T/F) for each overlay (e.g. ...&overlays=TFTT). Dynamically changing overlays in layer control will break it, because it relies on the sequence of the overlays in layer control.

It needs leaflet from github with merged pull request #1286 (layer control events for overlays): Leaflet/Leaflet#1286

Permalink.Overlay.js: http://pastebin.com/wChyR7bD

Feel free to reuse the code as you like!

Rotated marker loses its rotation while zooming [Marker.Rotate.js]

I have default marker rotated on 90 degrees and fixed like that.

var marker = new L.Marker([50, 80], { iconAngle: 90 });
map.addLayer(marker);

It works ok on static map, but when I zoom map in or out rotates back to 0 degrees. And after zoom transaction ends it rotates back to 90 degrees.

KML Style Color should to be inverted for CSS (bbggrr to rrggbb)

On vector/KML.js (

options.color = "#" + value.substring(2, 8);
) you extract color from color tag by value.substring(2, 8) but as says this KML documentation https://developers.google.com/kml/documentation/kmlreference#style , this tag is an « hexBinary value: aabbggrr », not, so rrggbb as in CSS.

I think that this line should be :

options.color = "#" + value.substring(6, 8) + value.substring(4, 6) + value.substring(2, 4);

Enhanced Google plugin with support for Adsense - but links are not clickable :-/

I enhanced your leaflet Google plugin to also display Google Adsense ads. See http://test.mapsmarker.com/?p=30 for an example. The code for this example can be found here: https://gist.github.com/4463745

unfortunately, the links in the ad are not clickable, although I tried everything that came into my mind (changing z-index, removing controls etc).

I guess that this might be a more common issue, as the link "Report problems" from Google is also not working.

Any help on this is really appreciated! In case you have an idea, you could also earn 30$ on http://test.mapsmarker.com/?p=30, where I am also looking for a solution ;-)

Problem when Google Maps API gets loaded multiple times

Hi Shramov,

I load Google APIs via Google loader in my plugin www.mapsmarker.com by the code
wp_enqueue_script( 'leafletmapsmarker-googlemaps-loader', 'https://www.google.com/jsapi?key='.$google_maps_api_key, array(), NULL);

and load the maps module via leaflet.js where I added
google.load("maps", "3", {other_params:"sensor=false&language="+leafletmapsmarker_L10n.lmm_googlemaps_language+leafletmapsmarker_L10n.lmm_googlemaps_libraries});

A user now reported a strange error which I could verify here: http://beta.mapsmarker.com/?p=42
When you try to drag the map, only the markers are moved around and not the map itself.

This is because the theme from the user also connects to the Google Maps API via
wp_enqueue_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=false', array(), false, true );

Do you happen to know if this behaviour can be prevent by changing your Google Maps plugin code or do I have to dequeue other Google Maps JS calls (which I wouldnt prefer as the other scripts could use parameter which I dont use).

Any help is appreciated!
regards,

Robert

Bing tiles fails to load when p.x or p.y is -ve

getTileUrl: function (p, z) {
var z = this._getZoomForUrl();
var subdomains = this.options.subdomains,
s = this.options.subdomains[Math.abs((p.x + p.y) % subdomains.length)];
return this._url.replace('{subdomain}', s)
.replace('{quadkey}', this.tile2quad(p.x, p.y, z))
.replace('{culture}', '');
}

Fix is use Math.abs while calculating subdomains as shown above

Tag a 0.1 version as beta or unstable or stable

Could you tag a 0.1 version of this or something so that other projects that depend on it have some sort of "stable" version to use? In a corporate environment it's difficult to say, "just use the latest version of everything" 😦

Geo object hide by layer?

This code (used yandex.js and google.js plug-ins):

var map = L.map('map').setView([51.505, -0.09], 13);
var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
var yndx = new L.Yandex();
var ggl = new L.Google();
map.addLayer(ggl);
map.addControl(new L.Control.Layers({ 'OSM': osm, "Yandex": yndx, "Google": ggl }));

var polygon = L.polygon([
    [51.509, -0.08],
    [51.503, -0.06],
    [51.51, -0.047]
]).addTo(map);

Polygon is displayed on the screen while adding/loading layers very short time. Finally, polygon displayed only at OSM layer.

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.