[OpenLayers-Users] geojson google maps zoom levels

Pierluigi Santin p.santin at fintelengineering.it
Tue Sep 29 04:24:27 EDT 2009


i must add that the problem occurs only in Internet explorer 7 or 8


  ----- Original Message ----- 
  From: Pierluigi Santin 
  To: users at openlayers.org 
  Sent: Monday, September 28, 2009 12:54 PM
  Subject: geojson google maps zoom levels


  i have a big problem
  i'm managing to overlay a geojson layer to google maps
  i did it succesfully
  my problem is that when i zoom in too much my geojson level disapperar
  i cannot get the problem
  can someone help me?

  this is the code
  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultOL.aspx.cs" Inherits="DefaultOL" %>

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html xmlns="http://www.w3.org/1999/xhtml">

  <head runat="server">

  <title></title>

  <script src="OpenLayers-2.8/OpenLayers.js" type="text/javascript"></script>

  <script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=it-it"></script> 

  <%--localhost google map key--%>

  <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>

  </head>

  <body>



  <form id="form1" runat="server">


  <asp:ScriptManager ID="ScriptManager1" runat="server">

  <Services>

  <asp:ServiceReference Path="~/MapService.asmx" />

  </Services>

  </asp:ScriptManager>



  <input type="button" onclick="getShape_onclick()" value="Overlay selected Shapefile" />

  mappa:

  <div id="map" style="width: 800px; height: 500px"></div>

  <script type="text/javascript">





  var map = null; 

  function pageLoad() {

  var options = {

  projection: new OpenLayers.Projection("EPSG:900913"),

  displayProjection: new OpenLayers.Projection("EPSG:4326"),

  units: "m",

  maxResolution: 156543.0339,

  maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,

  20037508.34, 20037508.34)

  //,numZoomLevels: 20

  };

  map = new OpenLayers.Map('map',options);

  var shaded = new OpenLayers.Layer.VirtualEarth("VE Shaded", { "sphericalMercator": true, type: VEMapStyle.Shaded });

  var hybrid = new OpenLayers.Layer.VirtualEarth("VE Hybrid", { "sphericalMercator": true, type: VEMapStyle.Hybrid });

  var aerial = new OpenLayers.Layer.VirtualEarth("VE Aerial", { "sphericalMercator": true, type: VEMapStyle.Aerial });

  var google = new OpenLayers.Layer.Google("Google Hybrid", { "sphericalMercator": true, type: G_HYBRID_MAP});





  map.addLayers([shaded, hybrid, aerial, google]);









  map.addControl(new OpenLayers.Control.LayerSwitcher());

  map.addControl(new OpenLayers.Control.MousePosition());

  map.setCenter(new OpenLayers.LonLat(1472482, 5794538), 5);

  }

  function getShape_onclick() {





  MapService.GetMapData('GBR1.shp', GetESRIData_success, onFailed);

  }

  function onFailed(e) {

  MessageBox(true, "Error while connecting to the remote web service. Please try again later.", 5000);

  }


  function GetESRIData_success(e) {

  //replace with call to webservice

  //var featurecollection = e;

  var featurecollection = {

  "type": "FeatureCollection",

  "features": [

  { "geometry": {

  "type": "GeometryCollection",

  "geometries": [

  {

  "type": "LineString",

  "coordinates":

  [[13.2, 46.1],

  [13, 46]]

  },

  {

  "type": "Polygon",

  "coordinates":

  [[[11.0878902207, 45.1602390564],

  [14.931640625, 40.9228515625],

  [0.8251953125, 41.0986328125],

  [7.63671875, 48.96484375],

  [11.0878902207, 45.1602390564]]]

  },

  {

  "type": "Point",

  "coordinates": [13.2, 46.1]

  }

  ]

  },

  "type": "Feature",

  "properties": {}

  }

  ]

  };

  var geojson_format = new OpenLayers.Format.GeoJSON({

  'internalProjection': new OpenLayers.Projection("EPSG:900913"),

  'externalProjection': new OpenLayers.Projection("EPSG:4326")

  });

  var vector_layer = new OpenLayers.Layer.Vector("shape");

  //var vector_layer = new OpenLayers.Layer.Vector("shape", { projection: map.displayProjection });

  map.addLayer(vector_layer);

  vector_layer.addFeatures(geojson_format.read(featurecollection));

  }

  //]]>

  </script> 

  </form>

  </body>

  </html>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090929/792b21e8/attachment.html


More information about the Users mailing list