Pick a location from Google Maps

Is this possible to pick a location from a map? Just like the 'What's here' option on the Google maps site?
3 answers

Added some code to the widget that invokes a microflow with a location object when a map is clicked: XML:

    <property key="EventEntity" type="entity">
        <category>Data source</category>
        <description>Event entity</description>
<property key="onChange" type="microflow" required="false" entityProperty="EventEntity">
    <caption>On change</caption>
    <description>Microflow to trigger on change.</description>
    <returnType type="Boolean"/>

(Extra attribute microflow and entity

displayMap : function (callback) {
        // added cdg 10-10-11
        var onClickMicroflow = this.onClickEvent;
        var ctxt = this.createContext();

And behind creating the map

// cdg 10-10-2011
            google.maps.event.addListener(this.googleMap, 'click', function(event) {
                if (onClickMicroflow) {
                        className   : "GoogleMaps.Location",
                        error       : function () {
                                        logger.debug("Create object failed.");
                        callback    : dojo.hitch(this, fillAttributesAfterCreate)
                function fillAttributesAfterCreate(mxObj){
                    mxObj.setAttribute("Longitude", event.latLng.lng());
                    mxObj.setAttribute("Latitude", event.latLng.lat());
                    ctxt.setContext(mxObj.getClass(), mxObj.getGUID());
                    // invoke microflow
                        actionname  : onClickMicroflow,
                        context     : ctxt,
                        callback    : function() {
                        error       : function(e) {
                            logger.error('Could not execute microflow: ' + onChangeMicroflow + 'with error: '+e&&e);

            //cdg 10-10-2011

not possible with the standard widget ...

You would need to extend the widget, to use AddMarker functionality.


This is not possible with the current widget no.

The Google Maps API is pretty big though, so I'm sure it can be made. You'll need to either file a Support Ticket or edit the Google Maps widget yourself though.

If all you want is to add a marker wherever the user clicks, that should be easy to add, as the AddMarker functionality is already used for making markers for the Mendix objects that are loaded in.