I'm trying to display GoogleMap(Google maps V3 JS) in UIWebView(ios6).
but,
When I moveing the map in webview,event no fire center_changed.
Move map has been completed, event fire.
Why?
...
Someone told me page:
http://gmaps-samples-v3.googlecode.com/svn/trunk/map_events/map_events.html
Mac' Safri access - fire center_changed while the map is moving.
iOS6 Safri access - move map is complete, fire center_changed.
...
I want to know the Center-Cordinates of the map while moving.
Please tell me a good way.
`<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: iPhone Geolocation</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
var moveCenterLat;
var moveCenterLng;
function initialize() {
var myOptions = {
zoom:reqZoomLevel,
disableDefaultUI:true,
draggable:true,
keyboardShortcuts:false,
scrollwheel:false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
google.maps.event.addListener(map, 'center_changed', function(){
var mce = map.getCenter();
moveCenterLat = mce.lat();
moveCenterLng = mce.lng();
});
}
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>`
It sounds like you want the
dragevent, notcenter_changed. From the Google Maps Javascript API V3 Reference:Something like this:
Edit: It seems the map bounds are no longer updated while dragging, so although the drag event does fire while the map is being dragged, both
getCenter()returns the coordinates of the map when the drag started. Thanks to @Zubair for pointing this out.