[OpenLayers-Users] (no subject)

Harish Chandran harishchandran19 at gmail.com
Fri Jan 22 14:57:13 EST 2010


Hello everyone. This is my first post and its about a problem I can't figure
out. I wanted to make a google map based interface with a marker pointing
specific locations. It all went well till I loaded the page. I can see my
map.but I can't see the marker. It is supposed to point at the map
center.Here is the code:

##############################
###################################################################################################################

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>User Interface</title>

<link rel="stylesheet"
href="file:///C:/Documents%20and%20Settings/N-compass/Desktop/UI/basicstyle.css"
/>

<link rel="stylesheet"
href="file:///C:/Documents%20and%20Settings/N-compass/Desktop/UI/google.css"
type="text/css" />

<link rel="stylesheet"
href="file:///C:/Documents%20and%20Settings/N-compass/Desktop/UI/style.css"
type="text/css" />

<script src='
http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ<http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ>
'></script>
<script src="http://openlayers.org/dev/OpenLayers.js"></script>

<script type="text/javascript">

    var map;
    var size, icon;

    function init(){

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


        var gphy = new OpenLayers.Layer.Google(
            "Google Physical",
            {type: G_PHYSICAL_MAP}
        );
        var gmap = new OpenLayers.Layer.Google(
            "Google Streets", // the default
            {numZoomLevels: 20}
        );
        var ghyb = new OpenLayers.Layer.Google(
            "Google Hybrid",
            {type: G_HYBRID_MAP, numZoomLevels: 20}
        );
        var gsat = new OpenLayers.Layer.Google(
            "Google Satellite",
            {type: G_SATELLITE_MAP, numZoomLevels: 20}
        );

        map.addLayers([gphy, gmap, ghyb, gsat]);



    var proj = new OpenLayers.Projection("EPSG:4326");
    var center = new OpenLayers.LonLat(72.856178,19.017656);
    center.transform(proj, map.getProjectionObject());

    map.setCenter(center,11);

    map.addLayer(layer);
    var markers = new OpenLayers.Layer.Markers( "Markers" );
    map.addLayer(markers);

    size = new OpenLayers.Size(15,15);
    calculateOffset = function(size) {return new
OpenLayers.Pixel(-(size.w/2), -size.h);};
    icon = new
OpenLayers.Icon('file:///C:/Documents%20and%20Settings/N-compass/Desktop/UI/marker.png',size,
null, calculateOffset);

    markers.addMarker(new OpenLayers.Marker(center,icon));

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

    }

</script>
</head>

    <body onload="init()">
        <h1 id="title">User Interface</h1>

        <div id="tags">
        </div>

        <p id="shortdesc">
            This project is still not over
        </p>

        <a style="float:right" href="" id="permalink">Permalink</a>

        <div id="map" class="smallmap" onclick="co-ordinate()"></div>

        <div id="docs"></div>
    </body>
</html>
########################################################################################################################################
The path to css and icon files have been changed to point to files in my
local directory. But they are the same files used in the openlayers
examples.

I know I am missing something very silly, can't figure it out. Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100123/1016880b/attachment.html


More information about the Users mailing list