mapstraction / mxn

A Javascript Mapping Abstraction library.
http://mapstraction.com/
Other
580 stars 132 forks source link

mapstraction not working on google map (click event and some methods) #281

Open vi3 opened 11 years ago

vi3 commented 11 years ago

Hi! included header scripts source: http://maps.googleapis.com/maps/api/js?sensor=false http://mapstraction.com/mxn/build/latest/mxn.js?(googlev3)

and main function: var map = new mxn.Mapstraction('map', 'googlev3'); // google map map.addEventListener('click', function(point) { alert(point.lat +","+ point.lon); // click event isn't triggered at all }); var latlon = new mxn.LatLonPoint(35.696216,51.422945); map.addLargeControls(); //not working map.setCenterAndZoom(latlon, 5);

so far I check some Mapstraction features and some methods like addSmallControls(),addLargeControls() didn't work on google and click event is not working on both openlayers and google map.

vicchi commented 11 years ago

Hi ... a couple of comments.

Firstly, you need a valid API key to use the Google v3 API, so your include should be ...

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY&sensor=SET_TO_TRUE_OR_FALSE"> </script>

Secondly, Google v3 passes the core Mapstraction tests, which exercises adding/removing controls as well as events. Take a look at the source code for the Google v3 example here: https://github.com/mapstraction/mxn/blob/release-3.0/examples/googlev3.html

If there is an issue, it would really help if you could provide a full working example (preferably as a Gist), rather than just a code snippet as above, so we can try and reproduce your problems with the exact source code you're using.