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

Custom Controls #6

Closed
ThorvaldAagaard opened this issue Aug 11, 2017 · 5 comments
Closed

Custom Controls #6

ThorvaldAagaard opened this issue Aug 11, 2017 · 5 comments

Comments

@ThorvaldAagaard
Copy link
Collaborator

Is it possible using this plugin to add a custom control, like described in https://developers.google.com/maps/documentation/javascript/examples/control-custom

@wf9a5m75
Copy link
Owner

Yes, possible. That's why JS developers use this plugin.
Just put any HTML elements on the map.

@wf9a5m75
Copy link
Owner

For example,

<div class="map" id="map_canvas1">
  <button ion-button (click)="onButton1_click($event)" >Click here</button></span>
</div>

@wf9a5m75
Copy link
Owner

But you don't need to put the element inside the map div tag.
This plugin recognizes z-index also.
If you set higher z-index than the map div, it is clickable.

@ThorvaldAagaard
Copy link
Collaborator Author

So instead of

        // Create the DIV to hold the control and call the CenterControl()
        // constructor passing in this DIV.
        var centerControlDiv = document.createElement('div');
        var centerControl = new CenterControl(centerControlDiv, map);

        centerControlDiv.index = 1;
        map.controls[google.maps.ControlPosition.TOP_CENTER].push(centerControlDiv);

I just add a div and reference that div in the code like this

        var centerControlDiv = document.getElementById('mapcustomdiv');
        var centerControl = new CenterControl(centerControlDiv, map);
        centerControlDiv.index = 1;

I know this could be done with styling, but just as an example of overlaying the map with custom html

@wf9a5m75
Copy link
Owner

https://github.com/wf9a5m75/ionic-googlemaps-demo/blob/master/src/pages/map/get-map/get-map.html#L121-L124

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

No branches or pull requests

2 participants