[OSM-dev] visual studio + OSM
Richard Duivenvoorde
rdmailings at duif.net
Tue Jun 2 08:38:40 BST 2009
Hi Mohamad,
don't know the reason, but running your file in a project here indeed
does NOT show a map (although in firebug you can see it's loading the
tiles). Apparently the height of the map is zero pixels.
Changing the map-div size to something in pixels, say:
<div style="width:500px; height:500px" id="map"></div>
shows the map immediately :-)
Regards,
Richard Duivenvoorde
Mohamad Ali wrote:
> Hi Guys,
>
> I tried to create a test project for OSM maps on visual studio, it has
> problem:
>
>
>
> I create a website C# project using visual studio 2005 , the content is
> this:
>
>
>
> <%@ Page Language="C#" AutoEventWireup="true" CodeFile="osmtest.aspx.cs"
> Inherits="osmtest" %>
>
>
>
> <!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>OpenStreetMap</title>
>
>
>
> <!-- bring in the OpenLayers javascript library
>
> (here we bring it from the remote site, but you could
>
> easily serve up this javascript yourself) -->
>
> <script src="http://www.openlayers.org/api/OpenLayers.js"
> type="text/javascript"></script>
>
>
>
> <!-- bring in the OpenStreetMap OpenLayers layers.
>
> Using this hosted file will make sure we are kept up
>
> to date with any necessary changes -->
>
> <script
> src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"
> type="text/javascript"></script>
>
>
>
> <script type="text/javascript">
>
> // Start position for the map (hardcoded here for simplicity,
>
> // but maybe you want to get from URL params)
>
> // (Though to get it from the URL it's simpler to use the
> Permalink and ArgParser controls)
>
> var lat = -37.8138524;
>
> var lon = 144.96494293;
>
> var zoom=13
>
>
>
> var map; //complex object of type OpenLayers.Map
>
>
>
>
>
>
>
> //Initialise the 'map' object
>
> function init() {
>
>
>
> map = new OpenLayers.Map ("map", {
>
> controls:[
>
> new OpenLayers.Control.Navigation(),
>
> new OpenLayers.Control.PanZoomBar(),
>
> new OpenLayers.Control.Attribution()],
>
> maxExtent: new
> OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
>
> maxResolution: 156543.0399,
>
> numZoomLevels: 19,
>
> units: 'm',
>
> projection: new OpenLayers.Projection("EPSG:900913"),
>
> displayProjection: new OpenLayers.Projection("EPSG:4326")
>
> } );
>
>
>
>
>
> // Define the map layer
>
> // Note that we use a predefined layer that will be
>
> // kept up to date with URL changes
>
> // Here we define just one layer, but providing a choice
>
> // of several layers is also quite simple
>
> // Other defined layers are OpenLayers.Layer.OSM.Mapnik,
> OpenLayers.Layer.OSM.Maplint and OpenLayers.Layer.OSM.CycleMap
>
> layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
>
> map.addLayer(layerMapnik);
>
>
>
>
>
> if( ! map.getCenter() ){
>
> var lonLat = new OpenLayers.LonLat(lon,
> lat).transform(new OpenLayers.Projection("EPSG:4326"),
> map.getProjectionObject());
>
> map.setCenter (lonLat, zoom);
>
> }
>
>
>
>
>
>
>
> }
>
>
>
> </script>
>
> </head>
>
>
>
> <!-- body.onload is called once the page is loaded (call the 'init'
> function) -->
>
> <body onload="init();">
>
>
>
> <!-- define a DIV into which the map will appear. Make it take up
> the whole window -->
>
> <div style="width:100%; height:100%" id="map"></div>
>
>
>
> </body>
>
>
>
> </html>
>
>
>
>
>
>
>
>
>
> THEN I run this project, it runs, it loads the images but it doesn’t
> display anything
>
>
>
> Any ideas?
>
>
>
> Thanks Guys
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> http://lists.openstreetmap.org/listinfo/dev
More information about the dev
mailing list