Google Maps
Test of move/zoom triggering code which could request new new marker data
by Ben Clayton
HTML
<script src="//maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="infx_map_0" class='infx-google-map google-map' style="width:100%; height:520px; overflow:hidden;"></div>
JavaScript
var infx_map_0 = {
map: null,
window: null,
point: null,
markers: [],
lat: ('' != '')?'':'50.85534',
lng: ('' != '')?'':'0.578',
zoom: 16,
marker_icon: function(img){
return new google.maps.MarkerImage("/x_icons/poi/"+img,
new google.maps.Size(16, 16), //icon size
new google.maps.Point(0,0), //icon origin
new google.maps.Point(11,9) //icon window anchor
);
},
add_marker: function(point,icon,name,desc,path){
var p = this;
var marker = new google.maps.Marker({
position:point,
icon:icon,
title:name,
desc:desc
});
this.markers.push(marker);
marker.setMap(this.map); //set the map
},
init: function(){
this.window = new google.maps.InfoWindow();
this.point = new google.maps.LatLng(this.lat,this.lng);
this.map = new google.maps.Map($("#infx_map_0").get(0),{
zoom: this.zoom,
center: this.point,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
// main center marker
new google.maps.Marker({
position: this.point,
map: this.map
});
var mainmap = this.map;
google.maps.event.addListener(
this, 'zoom_changed',
function(){this.update(mainmap)}
);
google.maps.event.addListener(
this.map, 'center_changed',
function(){this.update(mainmap)}
);
},
update: function(map){
var zoomLevel = map.getZoom();
console.log("Zoom:",zoomLevel);
var bounds = map.getBounds();
console.log("bounds:",bounds.getCenter() );
var proj = map.getProjection();
...