Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set KML overlay, might not be a bug but limitation with KML #30

Open
monkburger opened this issue Oct 8, 2014 · 1 comment
Labels

Comments

@monkburger
Copy link

Take for example this code:

    var kml = new aeris.maps.layers.AdvisoriesKML('http://gis.hamweather.net/kml/hwwarnings.kml');
    kml.setMap(map);

    var kmlLayer = new google.maps.KmlLayer({
    url: 'http://gis.hamweather.net/kml/hwwarnings.kml',
    suppressInfoWindows: false,
    preserveViewport: true,
    map: googleMap
    });

    google.maps.event.addListener(kmlLayer, 'click', function(kmlEvent) {
    var text = kmlEvent.featureData.description;
    showInContentWindow(text);
    });

There doesn't seem to be a function, kml.setZIndex (or set the opacity of any loaded KMLs)

No matter what, I cannot seem the set the KML layer to be under the radar image. Is this a limitation of gmaps+KML? For example, on the hamweather.com main page, you can see this behavior where the radar image is 'behind' the advisory.

@eschwartz
Copy link
Contributor

google.maps.KmlLayer does support a setZIndex method, though I would guess that it's only relative to other KML layers, so you may not be able to change its zIndex in relation to a radar layer. Aeris.js does not currently support a aeris.maps.layers.KML#setZIndex method, though you could directly call the method on the underlying gmaps view:

var gmapsKml = kml.getView();
gmapsKml.setZIndex(100);

Note that the google.maps.ImageMapType which is used to render tile layers does not support setting zIndex. I had to implement a custom ImageMapType object to handle z-indexes.

The reason we can use zIndexes on the HAMWeather page is that we're using aeris.maps.layers.Advisories, which is a tile image layer, not a kml layer.

A couple other things:

1: You can use the base aeris.maps.layers.KML layer. The AdvisoriesKML layer is simply a version of the KML layer, configured to use the http://gis.hamweather.net/kml/hwadv_all.kml endpoint. Also, note that KML accepts an attrs object, not a uri string as a constructor argument:

var kml = new aeris.maps.layers.KML({
  url: ''http://gis.hamweather.net/kml/hwwarnings.kml'
});

2: It looks like you're creating two KML layer object -- one Aeris.js object, and another gmaps object. I'm guessing that this is not what you're trying to do. If you're trying to get access to a click event, you can do so directly through the aeris object:

kml.on('click', function(latLon, data) {|
  var infobox = new aeris.maps.InfoBox({ 
    position: latLon,
    content: data.description
  });
  infoBox.setMap(map);
  // or whatever else you want to do here.
});

3: The aeris KML layer is currently setup to hardcode the suppressInfoWindows option as true. It would be nice if this wasn't hardcoded, though I did that in order to keep the behavior consistent with other mapping libraries. The good news is that's it's easy enough to popup your own info windows on click (as shown above).

The documentation for all this is sparse, to put it generously -- we're working on that. If you haven't yet, I would suggest taking a peek at the API reference docs. It's not super user-friendly, but it does list out all of the object attributes, events, and methods, which can be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants