Git Product home page Git Product logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Could you provide an example use case?  
What kind of "items" would you want to add/change?   

Can you provide a map and data that would use it? (modify your local version of 
geoxml3 with your proposed change and show it in action)

I would think if this was implemented, there should be similar callbacks for 
polylines and polygons.

Original comment by geocodezip on 28 Sep 2011 at 11:53

  • Added labels: Type-Enhancement, Priority-Low
  • Removed labels: Type-Defect, Priority-Medium

from geoxml3.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024

Original comment by geocodezip on 28 Sep 2011 at 11:53

from geoxml3.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Thanks for the response:

Use case:

I want to create my own listeners for the marker, in order to better manage
the infowindow mobile devices (particularly webkit browsers which by and
large don't manage embedded objects like youtube videos very well). I also
want to add my own attribute to the marker (to set a timeout option in this
particular case).

Yes, it is likely that polys need the same callback feature, although I
would make them separate callbacks.

the geoxml modification (*bold*) to createMarker() function:

 *if (!!parserOptions.pmParseMk) parserOptions.pmParseMk(marker, placemark);
**
* // Infowindow-opening event handler
   google.maps.event.addListener(marker, 'click', function() {
        this.infoWindow.close();
        marker.infoWindow.setOptions(infoWindowOptions);
        this.infoWindow.open(this.map, this);
    });

then in my js file, as part of the specification of the options passed to
geoXML3.parser(options):

        pmParseMk: (function addMarkerAttr (marker, placemark) {
            marker.waitTime = placemark.waitTime;
            google.maps.event.addListener(marker, 'click', function() {
                removeVideoFloatElement();
                this.infoWindow.timeLeft = marker.waitTime;
            });
            google.maps.event.addListener(marker.infoWindow, 'closeclick',
function() {
                removeVideoFloatElement();
            });
        })

I'm a little concerned about the two listeners for the same events (mine and
geoxml's), but it seems to work OK, at least for the current versions of the
API's.

JB

Original comment by [email protected] on 29 Sep 2011 at 1:17

from geoxml3.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
My approach is to pass a custom createMarker function as the createMarker 
option to the geoXML3.parser call: 

    function (placemark, document) {
        document.markers = document.markers || [];
        var found = false;
        if (document.reload) {
            for (var j = 0; j < document.markers.length; j++) {
                if (document.markers[j].getPosition().equals(placemark.latlng)) {
                    found = document.markers[j].active = true;
                    break;
                }
            }
        }
        if (!found) {
            var marker = kmlParser.createMarker(placemark, document);
            marker.active = true;
            google.maps.event.addListener(marker, "click", function () { ... do something ... });
        }
    }

My own createMarker function calls the built-in createMarker function, and then 
adds the listener. It works fine, as far as I can see.

The down side is that I had to duplicate some of the code in the render 
function to make it work. For example, if I leave out the

    document.markers = document.markers || [];

line, the built-in createMarker function no longer works. Ideally, I think, my 
function would have read like this:

    var marker = kmlParser.createMarker(placemark, document);
    google.maps.event.addListener(marker, "click", function () { ... do something ... });

Original comment by [email protected] on 21 Dec 2011 at 1:33

from geoxml3.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
And a question about this part:

    if (doc.markers[j].getPosition().equals(placemark.latlng)) {
        found = doc.markers[j].active = true;

Are two markers identical if they have the same latlng position? What if I have 
two markers at the same position? What if an update to a previously loaded kml 
document has a marker with an unchanged position, but a change in the name, or 
description? If I understand the code correctly, these changes would be ignored?

Original comment by [email protected] on 21 Dec 2011 at 1:38

from geoxml3.

Related Issues (20)

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.