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

MeasureTool click event on marker and polygon #38

Closed
tuyenlaptrinh opened this issue Apr 21, 2018 · 4 comments
Closed

MeasureTool click event on marker and polygon #38

tuyenlaptrinh opened this issue Apr 21, 2018 · 4 comments
Assignees
Labels

Comments

@tuyenlaptrinh
Copy link

My map using many marker and polygon. When I start measure tool I can not start or click on polygon or marker.

I can not publish my app.

this is my map option

var myOptions = {
                    zoom:zoom,
                    minZoom: wpgmza_max_zoom,
                    maxZoom: wpgmza_min_zoom,
                    center: latLng,
                    draggable: wpgmza_settings_map_draggable,
                    disableDoubleClickZoom: wpgmza_settings_map_clickzoom,
                    scrollwheel: wpgmza_settings_map_scroll,
                    zoomControl: wpgmza_settings_map_zoom,
                    panControl: wpgmza_settings_map_pan,
                    mapTypeControl: wpgmza_settings_map_type,
                    streetViewControl: wpgmza_settings_map_streetview,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    scaleControl: true,
                    
                  };

image

this is callback

measureTool = new MeasureTool(this.map, {
            unit: MeasureTool.UnitTypeId.METRIC,
            contextMenu: false,
        });
        measureTool.addListener('measure_change',(e)=>{
            var typeMea = jQuery('#measure_tool_type').val();
            var result = e.result;
            console.log(result);
            if(typeMea == 'distance' && result.length > 0){
                jQuery('.current-measurement').empty();
                jQuery('.current-measurement').append('<p>'+result.lengthText+'</p>');
            }
            if(typeMea == 'area' && result.area > 0){
                jQuery('.current-measurement').empty();
                var areaConver = result.area*0.000247105;
                jQuery('.current-measurement').append('<p>'+result.areaText+'</p><p>'+areaConver.toFixed(2)+' acre</p>');
            }
            
        });

Please help #me.

@zhenyanghua
Copy link
Owner

Please use this template to reproduce the issue you have to help with trouble-shooting. Thanks.

@tuyenlaptrinh
Copy link
Author

tuyenlaptrinh commented Apr 22, 2018

I don't understand. What line is important in that template.

or I need add addListener after add marker or Pogylon

https://jsbin.com/kuyenu/edit?html,output
This is not working. You can see RED BOX is polygon

Thank you for quick reply

@zhenyanghua
Copy link
Owner

This is an expected behavior. You should use the callback event to toggle the clickable setting on your google geometries.

Here is an example:

measureTool.addListener('measure_start', function() {
      polygon.setOptions({clickable: false});
    });
measureTool.addListener('measure_end', function() {
      polygon.setOptions({clickable: true});
    });

https://jsbin.com/gotatoxifa/5/edit?html,output

@tuyenlaptrinh
Copy link
Author

Thank you so much. It is working fine now. You are genuis

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