User Tools

Site Tools


maps:anglorum

Anglorum

<html>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBeXtLpX49xgl0UWXCxYOdJBe7CcMqEHdk&sensor=false"></script> 
<script type="text/javascript"> 
  var mapTypes = {};

set up the map types mapTypes['Anglorum'] = { getTileUrl: function(coord, zoom) { return “http://localhost:8080/ms/m/Europe_Map_Region_Anglorum/” + zoom + “/” + coord.x + “/” + coord.y; }, tileSize: new google.maps.Size(256, 256), isPng: false, maxZoom: 4, minZoom: 0, name: 'Anglorum', credit: 'ArmourEE' }; var map; var mapTypeIds = []; Setup a copyright/credit line, emulating the standard Google style

  var creditNode = document.createElement('div');
  creditNode.id = 'credit-control';
  creditNode.style.fontSize = '11px';
  creditNode.style.fontFamily = 'Arial, sans-serif';
  creditNode.style.margin = '0 2px 2px 0';
  creditNode.style.whitespace = 'nowrap';
  creditNode.index = 0;

function setCredit(credit) {

    creditNode.innerHTML = credit + ' -';
  }

function initialize() {

push all mapType keys in to a mapTypeId array to set in the mapTypeControlOptions for (var key in mapTypes) { mapTypeIds.push(key); } var mapOptions = { zoom: 0, center: new google.maps.LatLng(0, 0), mapTypeControlOptions: { mapTypeIds: mapTypeIds, style: google.maps.MapTypeControlStyle.DROPDOWN_MENU } }; map = new google.maps.Map(document.getElementById(“map_canvas”), mapOptions); push the credit/copyright custom control

    map.controls[google.maps.ControlPosition.BOTTOM_RIGHT].push(creditNode);
    
    function EuclideanProjection() {
        var EUCLIDEAN_RANGE = 256;
        this.pixelOrigin_ = new google.maps.Point(EUCLIDEAN_RANGE / 2,
                   EUCLIDEAN_RANGE / 2);
        this.pixelsPerLonDegree_ = EUCLIDEAN_RANGE / 360;
        this.pixelsPerLonRadian_ = EUCLIDEAN_RANGE / (2 * Math.PI);
        this.scaleLat = 3.0625;        // Height - multiplication scale factor
        this.scaleLng = 3.0625;        // Width - multiplication scale factor
        this.offsetLat = 0;        // Height - direct offset +/-
        this.offsetLng = 0;        // Width - direct offset +/-
    };
    EuclideanProjection.prototype.fromLatLngToPoint = function(latLng, opt_point) {
        var point = opt_point || new google.maps.Point(0, 0);
        var origin = this.pixelOrigin_;
        point.x = (origin.x + (latLng.lng() + this.offsetLng ) *
                   this.scaleLng * this.pixelsPerLonDegree_);
        // NOTE(appleton): Truncating to 0.9999 effectively limits latitude to
        // 89.189.  This is about a third of a tile past the edge of the world tile.
        point.y = (origin.y + (-1 * latLng.lat() + this.offsetLat ) *
                   this.scaleLat * this.pixelsPerLonDegree_);
        return point;
    };
    EuclideanProjection.prototype.fromPointToLatLng = function(point) {
        console.log("fromPointToLatLng:",point.y,point.x);
        var me = this;
        var origin = me.pixelOrigin_;
        var lng = (((point.x - origin.x) / me.pixelsPerLonDegree_) /
                this.scaleLng) - this.offsetLng;
        var lat = ((-1 *( point.y - origin.y) / me.pixelsPerLonDegree_) /
                   this.scaleLat) - this.offsetLat;
        return new google.maps.LatLng(lat , lng, true);
    };
    prj = new EuclideanProjection();

add the new map types to map.mapTypes for (key in mapTypes) { mapType = new google.maps.ImageMapType(mapTypes[key]); map.mapTypes.set(key, mapType); mapType.projection = prj; } handle maptypeid_changed event to set the credit line

    google.maps.event.addListener(map, 'maptypeid_changed', function() {
      setCredit(mapTypes[map.getMapTypeId()].credit);
    });

start with the world map type map.setMapTypeId('Anglorum'); set up the markers new google.maps.Marker({ position: prj.fromPointToLatLng(new google.maps.Point(535.1988,383.71255, true)), map: map, icon: '/maps/icons/spawn-red.png', title: '1\/1 - Speak with King Arthur Pendragon' }); new google.maps.Marker({ position: prj.fromPointToLatLng(new google.maps.Point(551.8143,381.87363, true)), map: map, icon: '/maps/icons/questgiver.png', title: 'The Shadow Legion - Start' });

maps/anglorum.txt · Last modified: 2012/09/01 16:30 (external edit)