Monday, August 02, 2010

Google maps - Part 3 - How to create a marker on google maps?

Markers are indicators on google map to denote the places of interest. This post will explain you how to place a marker on google map.

The marker object resides in the google.maps.Marker namespace and takes a single argument, options. Options is an object literal called Marker options that can have several properties of which two are required:

map [Map]
Map is a reference to the map where you want to add the marker.

position [LatLng]
This property indicates the position of the marker and is of type google.maps.LatLng

How to copy a DLL from the GAC

I was trying to copy the System.Web.Extensions dll from the GAC to my application bin folder. You can do that using the following command.

solution
copy "C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35" C:\temp\project\bin

Sunday, August 01, 2010

How to escape XML text in c#?

Escaping XML text is basically encoding the following symbols (<, >, &, ", ').

This can be done in the following ways.

a) Using Replace function

string xmlData = "I live in \"wellington\" & I love listening to music."
string escapedXmlData = xmlData.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "&apos;");

Note: Replace the & symbol first.

b) Using System.Security.SecurityElement.Escape() method

string xmlData = "I live in \"wellington\" & I love listening to music."

string escapeXmlData = System.Security.SecurityElement.Escape(xmlData);

Thursday, July 29, 2010

Google maps - Part 2 - How to get current lat, lng and zoom level

Once a google map is initialized and when it is re-positioned, the latitude, longitude and zoom level can be determined using the following example.

Monday, July 26, 2010

Google maps API v3 - Part 1 - How to create a simple map?

Recently I worked on a project using Google maps. It was originally developed using Google maps API v2. I changed it to use v3 API.

Google maps v2 vs v3 API

Version 2 API requires you to register for an API key for every domain that uses google maps and must be inserted into the QueryString for the script reference. Version 3 API doesn't require an API key.

How to create a simple map?

1. First thing is to add the following script reference to your HTML page.


Note: sensor attribute is to specify whether your device has a sensor or not. (just to determine the user's location.

2. Create an object with the latitude and longitude co-ordinates. Simple map with NZ co-ordinates.