Coder Social home page Coder Social logo

Comments (7)

egeloen avatar egeloen commented on September 18, 2024

Thanks ! Unfortunately, I dont' have any time actually, i'm totally busy but I'm ok to add KML support to the bundle.

I'll explain you what I would have done if I had time.
So, If you want, you can do it and i will merge it :)

IMO, after looking the google map doc, we need to create a KMLLayer class which extends AbstractJavascriptVariableAsset and will be stored under the Model/Layers directory.
This class will describe the kml layer options according to KMLLayer and KMLLayerOptions.

To link the kml layer to the map, we need to add a kmlLayer property to the Map and this getter & setter. Additionnaly, we need to add a convenient method called hasKMLLayer() to check if the map has a kml layer (This method will be usefull in the helper). If the kmlLayer property is null, there is no kml layer otherwise there is.

After that, we need to create a KMLLayerHelper class which will render the javascript. This class will be stored under the Templating/Helper/Layers dicretory. I think, it will just have one method (render(KMLLayer $layer) which will return the KML layer javascript.

Now, we have our business and templating classes, we need to create the associated symfony2 services to allow users to request a kml layer in their controllers. The KMLLayer service can be named ivory_google_map.kml_layer and the KMLLayerHelper can be named ivory_google_map.helper.kml_layer. The KMLLayerHelper service is not public, it is created to be injected into the ivory_google_map.helper.map which renders a map and so will render the kml layer.
So , to finish, we need to inject this service, update the MapHelper constructor to accept the KMLLayerHelper injected, create a new method called renderKMLLayer(Map $map) where we will use the KMLLayerHelper if the map has a kml layer.

If you have some questions, I'm here :)

from ivorygooglemapbundle.

cbeyer avatar cbeyer commented on September 18, 2024

Thanks for the explanations. Unfortunately, I'm busy too, I have never use Github for pull request, and I don't think I could make what required is...
Here is my JS code. I will continue add this "at hand" until this bundle integrate this.

var kmlLayerOptions = {
preserveViewport: true // for example
}
var ctaLayer = new google.maps.KmlLayer('http://myUrl.kml', kmlLayerOptions);
ctaLayer.setMap(map);

from ivorygooglemapbundle.

wodor avatar wodor commented on September 18, 2024

I'll need this also in near future. I've looked around to implement it, and have some questions :

  • how do you know which fields and methods to add to KmlLayerClass , as i compared classes from Model with docs i see it's not 1:1 , any guides ? (I decided to implement helper and add fields to KmlLayer 'on demand')
  • I have decided to extend AbstractOptionsAsset instead of AbstractJavascriptVariableAsset to have options
  • I've noticed that there can be many layers on one map (at least you can have many layers and do setMap() ) so I've added kmlLayers instead of kmlLayer , addKmlLayer method and no hasKmlLayers , just like ground Overlay
  • Isn't KmlLayer just an overlay (is it worth to create separate namespce Layers)

I had limited time today so It's just a beginning.

https://github.com/wodor/IvoryGoogleMapBundle/tree/kmlSupport

btw i had problem with :

/home/wodor/wrk/www/motowypady/vendor/bundles/Ivory/GoogleMapBundle/Model/Overlays/Polygon.php on line 14

after

it's fixed

another problem
maybe it's my own , but it seems that phpunit run in bundle's root doesn't excludes vendor dir (like it's specified in phpunit.xml.dist) i can only do i.e.


from ivorygooglemapbundle.

egeloen avatar egeloen commented on September 18, 2024

This issue can be closed :)

from ivorygooglemapbundle.

cbeyer avatar cbeyer commented on September 18, 2024

Great, thanks ! I will test this.

from ivorygooglemapbundle.

cbeyer avatar cbeyer commented on September 18, 2024

And it works great :)

from ivorygooglemapbundle.

egeloen avatar egeloen commented on September 18, 2024

Thanks for feedbacks !

from ivorygooglemapbundle.

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.